Python知識(shí)分享網(wǎng) - 專業(yè)的Python學(xué)習(xí)網(wǎng)站 學(xué)Python,上Python222
Android Programming The Big Nerd Ranch Guide 第五版 PDF 下載
匿名網(wǎng)友發(fā)布于:2023-12-24 10:37:18
(侵權(quán)舉報(bào))
(假如點(diǎn)擊沒(méi)反應(yīng),多刷新兩次就OK!)

Android Programming The Big Nerd Ranch Guide 第五版 PDF 下載  圖1

 

 

 

資料內(nèi)容:

 

Instrumented Tests with Espresso and
ActivityScenario
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 also some
differences: First, the class itself has an annotation,
@RunWith(AndroidJUnit4::class), which signals to JUnit that
this test should be executed on an Android device. And the test function
relies on the Android SDK, specifically to verify that the app’s package
name is the same as the value you set when you created the app.
You are about to run ExampleInstrumentedTest, but you have some
housekeeping to take care of first. Since instrumented tests run on an
Android device, not your development machine, you need to either connect
an Android device, as you did in Chapter 2, or run an emulator. Make sure
the device dropdown at the top of the Android Studio window shows the