标签:
编写用例,方法必须test开头。如:
public void testDemo() { UiDevice.getInstance().pressHome(); }
运行测试
adb shell uiautomator runtest <jars> -c <包名>.<类名>[#test name]
e :传入一个键值对到测试程序中,可用于一些需要变化的参数的传入
在测试用例中添加使用参数的代码,如获取手机号码
public void testDemo() { UiDevice.getInstance().pressHome(); Bundle bundle = getParams(); String phone = bundle.getString("phone"); System.out.println("Phone: " + phone); }
在测试类中新建main函数,如
public static void main(String[] args) { String jarName = "Demo"; //jar包名称 String testClass = "com.test.Test"; //测试类全名 String testCaseName = "testDemo"; //测试用例名 String androidId = "1"; new UiAutomatorHelper(jarName, testClass, testCaseName, androidId); }
标签:
原文地址:http://www.cnblogs.com/WangKangReg/p/4379590.html