

It should also be noted that Telerik's online documentation is rich with examples, tutorials, and real-working demos. The ability to create rich, interactive UI's without the hassle of rolling our own controls has been incredibly valuable. Just change your module’s adle and add the flavor.Using Telerik UI, we were able to boost our speed to production by over 50%. To achieve this, you might add a mock build flavor to apps which contain utilities for testing views (and Activities / Fragments). Ideally, we’d like to have the custom view separated to allow us to completely focus on the view itself, without distractions. However, since we are focusing on custom views, we don’t really want to start the Activity our view is contained in, since that would be overkill. We can then check if the view is behaving correctly.Įspresso provides test rules to start Activities which are being tested. In Espresso tests, we can simulate certain user behaviors like tapping on buttons, swiping left and right or typing text. For example, that certain views are visible and contain the information they should contain at the right times. With Espresso, we can verify our UI’s behavior. Now that we’ve covered the logic side of our view, its time to take a look at UI tests.

It’s just as easy to implement these architectures in custom views, to separate logic from the view itself - resulting in a unit-testable logic layer and a UI-testable view layer. Luckily, architectures like MVP and MVVM are not required to be used with Activity and Fragment exclusively. However, since at the moment our custom view class is just extending or a layout, there’s no practical way to do this. To reduce both the time we have to spend writing the test and the time it takes to execute it, we’ll shift most of the testing into our unit test layer. It takes time to write them properly and it takes time to execute them, since you’ll need to boot an emulator or install on a physical device. Thinking about testing a custom view, you’d most likely consider UI tests with Espresso. To further reduce errors, we are going to add some tests to ensure that everything is working as intended - i.e. Smaller modules mean less responsibility and thus less room for errors. Not every custom component has to be an Activity or Fragment. Writing a custom view to encapsulate certain functions makes sense.
