Java知识分享网 - 轻松学习从此开始!    

Java知识分享网

        
AI编程,程序员挑战年入30~100万高级指南 - 职业规划
SpringBoot+SpringSecurity+Vue权限系统高级实战课程        

IDEA永久激活

Java微信小程序电商实战课程(SpringBoot+VUe)

     

AI人工智能学习大礼包

     

PyCharm永久激活

66套java实战课程无套路领取

     

Cursor+Claude AI编程 1天快速上手视频教程

     
当前位置: 主页 > Java文档 > Java基础相关 >

Android Programming The Big Nerd Ranch Guide 第五版 PDF 下载


时间:2023-12-24 10:43来源:http://www.java1234.com 作者:转载  侵权举报
Android Programming The Big Nerd Ranch Guide 第五版
失效链接处理
Android Programming The Big Nerd Ranch Guide 第五版 PDF 下载

 
 
 
相关截图:
 


主要内容:


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
 


 
 
 
------分隔线----------------------------


锋哥推荐