Testing Android Activities

Here’s how to create a test to check the initial state for the Timer activity.

1. Create a new Android test project named On Your Bike - Chapter 10 - Tests. Select On Your Bike - Chapter 10 as the project to test, as shown in Figure 10.8.

Image

Figure 10.8 Creating an Android test project

2. Open the generated Android manifest, and see that it contains an instrumentation node:

<instrumentation    android:name="android.test.InstrumentationTestRunner"     android:targetPackage="com.androiddevbook.onyourbike.chapter10" />

3. Inside the newly created tests package, create a new JUnit test case named ...

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.