May 2022
Intermediate to advanced
688 pages
20h 12m
English
Let’s move on to instrumented tests. Begin by checking out the example that Android Studio created. In com.bignerdranch.android.geoquiz (androidTest), find and open ExampleInstrumentedTest.kt:
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.bignerdranch.android.geoquiz", appContext.packageName)
}
}
Much of this code is similar to the tests you have seen so far: You have a class containing a function annotated with @Test, and within that function there is an assertion to verify some behavior. But there are ...
Read now
Unlock full access