Summary

In this chapter, several real-world examples of tests that cover a wide range of cases were presented. You can use them as a starting point while creating your own tests.

We covered a variety of testing recipes that you can extend for your own tests. We used mock contexts and showed how RenamingDelegatingContext can be used in various situations to change the data obtained by the tests. We also analyzed the injection of these mock contexts into test dependencies.

Then, we used ActivityUnitTestCase to test Activities in complete isolation. We tested Views in isolation using AndroidTestCase. We demonstrated the use of Mockito to mock objects combined with ArgumentMatchers to provide custom matchers on any object. Finally, we treated the analysis ...

Get Learning Android Application Testing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.