1.在需要测试的项目下build.gradle中添加依赖androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.0' minSdkVersion 15 替换 18
2.项目名--app-src-androidTest--java /路径下编写测试用例
3.注意测试用例的编写规范 ,类名头上添加@RunWith(AndroidJUnit4.class),方法名头上添加@Test
eg:
@RunWith(AndroidJUnit4.class)
public class SalaryShowAppTest {
private final String Tag= getClass().getName();
private String mPackagename="包名"
@Test
public void case1(){
UiDevice mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());//获取设备用例
..................
}
4.右键 --run
网友评论