Creating a New Test Application
In this section, you’ll create your first JUnit test app. Test applications are separate from your main app, but they use the app’s code. In this way, your test code does not increase the size of your app or accidentally get deployed on an app store.
When writing tests, your goal is to make each test small and have the tests cover all possible lines of code, and branches throughout the code, as much as is possible. Code coverage tools help you measure the percentage of code coverage and monitor the coverage over time. This gives you some idea of whether your code is being adequately tested.
To write a JUnit test app, follow these steps.
1. Open TimerState.java
in the model
package. Review the existing methods, ...
Get Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications 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.