Creating the TemperatureConverterActivityTests class
Proceed with creating the first test by selecting the main test package name, com.blundell.tut.
This is under src/androidTest/Java
in the AndroidStudio project view, or under app/java/(androidTest)
in the AndroidStudio Android view. Then right-click here, and select New | Java Class, call it, TemperatureConverterActivityTests
.
Once the class is created, we need to go about turning it into a test class. We should select our superclass depending on what and how we are going to test. In Chapter 2, Understanding Testing with the Android SDK, we reviewed the available alternatives. Use it as a reference when you try to decide what superclass to use.
In this particular case, we are testing a single Activity and using the system infrastructure, therefore, we should use ActivityInstrumentationTestCase2
. Also note that as ActivityInstrumentationTestCase2
is a generic class, we need the template parameter as well. This is the Activity under test,...