UiAutomator 新手初学 uiAutomator-遇到老是提示找不到测试方法。但是明明有此测试方法,且有的方法可以正常执行,有的就一直报找不到方法。求解啊。网上找不到资料

王彩虹 · February 09, 2017 · Last by rainbow_xy replied at February 20, 2017 · 1589 hits

有一个最简单的方法如下:
public void testScreen(){
UiDevice.getInstance().takeScreenshot(new File("/sdcards/test1.png"));
}
然后main方法调用此方法运行:
public static void main(String[] args) {
String jarName="Demoone";
String testClass="com.wch.Demo1";
String testName="testScreen";
String androidId="10";
new UiAutomatorHelper(jarName, testClass, testName, androidId);

}
然后控制台:

-----------start--uiautomator--debug-------------
----工作空间:
E:\android-workspace\Test
----execCmd: cmd /c android create uitest-project -n Demoone -t 10 -p "E:\android-workspace\Test"

Updated file E:\android-workspace\Test\build.xml

--------修改build完成---------
----execCmd: cmd /c ant
Buildfile: E:\android-workspace\Test\build.xml

-check-env:
[checkenv] Android SDK Tools Revision 25.2.5
[checkenv] Installed at D:\adt-bundle\sdk

-build-setup:
[getbuildtools] Using latest Build Tools: 23.0.3
[echo] Resolving Build Target for Demoone...
[getuitarget] Project Target: Android 4.4W.2
[getuitarget] API level: 20
[echo] ----------
[echo] Creating output directories if needed...

-pre-compile:

compile:
[javac] Compiling 1 source file to E:\android-workspace\Test\bin\classes
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:23: 警告: 编码UTF-8的不可映射字符
[javac] //getUiDevice().pressHome();//??????????????Щ???????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:39: 警告: 编码UTF-8的不可映射字符
[javac] UiObject clock=new UiObject(new UiSelector().resourceId("com.android.gallery3d:id/appwidget_album_name"));//?????????????汾???????????????4.3?汾????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:56: 警告: 编码UTF-8的不可映射字符
[javac] * ????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:56: 警告: 编码UTF-8的不可映射字符
[javac] * ????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:56: 警告: 编码UTF-8的不可映射字符
[javac] * ????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:56: 警告: 编码UTF-8的不可映射字符
[javac] * ????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:56: 警告: 编码UTF-8的不可映射字符
[javac] * ????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:56: 警告: 编码UTF-8的不可映射字符
[javac] * ????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:61: 警告: 编码UTF-8的不可映射字符
[javac] // //??????е?
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:61: 警告: 编码UTF-8的不可映射字符
[javac] // //??????е?
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:61: 警告: 编码UTF-8的不可映射字符
[javac] // //??????е?
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:61: 警告: 编码UTF-8的不可映射字符
[javac] // //??????е?
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:61: 警告: 编码UTF-8的不可映射字符
[javac] // //??????е?
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:61: 警告: 编码UTF-8的不可映射字符
[javac] // //??????е?
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:64: 警告: 编码UTF-8的不可映射字符
[javac] // //???????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:64: 警告: 编码UTF-8的不可映射字符
[javac] // //???????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:64: 警告: 编码UTF-8的不可映射字符
[javac] // //???????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:64: 警告: 编码UTF-8的不可映射字符
[javac] // //???????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:64: 警告: 编码UTF-8的不可映射字符
[javac] // //???????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:64: 警告: 编码UTF-8的不可映射字符
[javac] // //???????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:67: 警告: 编码UTF-8的不可映射字符
[javac] // //?????С??????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:67: 警告: 编码UTF-8的不可映射字符
[javac] // //?????С??????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:67: 警告: 编码UTF-8的不可映射字符
[javac] // //?????С??????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:67: 警告: 编码UTF-8的不可映射字符
[javac] // //?????С??????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:67: 警告: 编码UTF-8的不可映射字符
[javac] // //?????С??????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:67: 警告: 编码UTF-8的不可映射字符
[javac] // //?????С??????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:67: 警告: 编码UTF-8的不可映射字符
[javac] // //?????С??????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:67: 警告: 编码UTF-8的不可映射字符
[javac] // //?????С??????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:67: 警告: 编码UTF-8的不可映射字符
[javac] // //?????С??????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:67: 警告: 编码UTF-8的不可映射字符
[javac] // //?????С??????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:75: 警告: 编码UTF-8的不可映射字符
[javac] // //????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:75: 警告: 编码UTF-8的不可映射字符
[javac] // //????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:75: 警告: 编码UTF-8的不可映射字符
[javac] // //????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:75: 警告: 编码UTF-8的不可映射字符
[javac] // //????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:75: 警告: 编码UTF-8的不可映射字符
[javac] // //????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:75: 警告: 编码UTF-8的不可映射字符
[javac] // //????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:75: 警告: 编码UTF-8的不可映射字符
[javac] // //????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:75: 警告: 编码UTF-8的不可映射字符
[javac] // //????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:75: 警告: 编码UTF-8的不可映射字符
[javac] // //????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:75: 警告: 编码UTF-8的不可映射字符
[javac] // //????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:84: 警告: 编码UTF-8的不可映射字符
[javac] //??????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:84: 警告: 编码UTF-8的不可映射字符
[javac] //??????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:84: 警告: 编码UTF-8的不可映射字符
[javac] //??????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:84: 警告: 编码UTF-8的不可映射字符
[javac] //??????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:84: 警告: 编码UTF-8的不可映射字符
[javac] //??????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:84: 警告: 编码UTF-8的不可映射字符
[javac] //??????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:99: 警告: 编码UTF-8的不可映射字符
[javac] * ?????? ????????????????????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:99: 警告: 编码UTF-8的不可映射字符
[javac] * ?????? ????????????????????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:99: 警告: 编码UTF-8的不可映射字符
[javac] * ?????? ????????????????????????????????
[javac] ^
[javac] E:\android-workspace\Test\src\com\wch\Demo1.java:5: 错误: 程序包java.rmi.server不存在
[javac] import java.rmi.server.UID;
[javac] ^
[javac] 1 个错误
[javac] 100 个警告

BUILD FAILED
D:\adt-bundle\sdk\tools\ant\uibuild.xml:183: Compile failed; see the compiler error output for details.

Total time: 1 second
----jar包路径: "E:\android-workspace\Test\bin\Demoone.jar"
----adb push "E:\android-workspace\Test\bin\Demoone.jar" /data/local/tmp/
----execCmd: adb push "E:\android-workspace\Test\bin\Demoone.jar" /data/local/tmp/
[100%] /data/local/tmp/Demoone.jar
----runTest: adb shell uiautomator runtest Demoone.jar --nohup -c com.wch.Demo1#testScreen
----execCmd: adb shell uiautomator runtest Demoone.jar --nohup -c com.wch.Demo1#testScreen
INSTRUMENTATION_STATUS: numtests=1

INSTRUMENTATION_STATUS: stream=

com.wch.Demo1:

INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner

INSTRUMENTATION_STATUS: test=testScreen

INSTRUMENTATION_STATUS: class=com.wch.Demo1

INSTRUMENTATION_STATUS: current=1

INSTRUMENTATION_STATUS_CODE: 1

INSTRUMENTATION_STATUS: numtests=1

INSTRUMENTATION_STATUS: stream=

Failure in testScreen:

junit.framework.AssertionFailedError: Method "testScreen" not found

at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:160)

at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:96)

at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:91)

at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)

at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)

at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:251)

INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner

INSTRUMENTATION_STATUS: test=testScreen

INSTRUMENTATION_STATUS: class=com.wch.Demo1

INSTRUMENTATION_STATUS: stack=junit.framework.AssertionFailedError: Method "testScreen" not found

at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:160)

at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:96)

at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:91)

at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)

at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)

at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:251)

INSTRUMENTATION_STATUS: current=1

INSTRUMENTATION_STATUS_CODE: -2

INSTRUMENTATION_STATUS: stream=

Test results for WatcherResultPrinter=.F

Time: 0.044

FAILURES!!!

Tests run: 1, Failures: 1, Errors: 0

INSTRUMENTATION_STATUS_CODE: -1


---FINISH DEBUG----


共收到 8 条回复 时间 点赞

姑娘在这里比较有优势~

#1楼 @342164796 可是没人回答我的问题。

还老出现以下问题:
BUILD FAILED
D:\adt-bundle\sdk\tools\ant\uibuild.xml:183: Compile failed; see the compiler error output for details.

Total time: 1 second
----jar包路径: "E:\android-workspace\Test\bin\Demoone.jar.jar"
----adb push "E:\android-workspace\Test\bin\Demoone.jar.jar" /data/local/tmp/
----execCmd: adb push "E:\android-workspace\Test\bin\Demoone.jar.jar" /data/local/tmp/
adb: error: cannot stat 'E:\android-workspace\Test\bin\Demoone.jar.jar': No such file or directory
----runTest: adb shell uiautomator runtest Demoone.jar.jar --nohup -c com.wch.Demo1#testPress
----execCmd: adb shell uiautomator runtest Demoone.jar.jar --nohup -c com.wch.Demo1#testPress
Error: /data/local/tmp/Demoone.jar.jar does not exist

Usage: uiautomator [options]

Available subcommands:

help: displays help message

runtest: executes UI automation tests

runtest [options]

: < -c | -e class >

: a list of jar files containing test classes and dependencies. If

the path is relative, it's assumed to be under /data/local/tmp. Use

absolute path if the file is elsewhere. Multiple files can be

specified, separated by space.

: a list of test class names to run, separated by comma. To

a single method, use TestClass#testMethod format. The -e or -c option

may be repeated. This option is not required and if not provided then

all the tests in provided jars will be run automatically.

options:

--nohup: trap SIG_HUP, so test won't terminate even if parent process

is terminated, e.g. USB is disconnected.

-e debug [true|false]: wait for debugger to connect before starting.

-e runner [CLASS]: use specified test runner class instead. If

unspecified, framework default runner will be used.

-e : other name-value pairs to be passed to test classes.

May be repeated.

-e outputFormat simple | -s: enabled less verbose JUnit style output.

dump: creates an XML dump of current UI hierarchy

dump [--verbose][file]

[--compressed]: dumps compressed layout information.

[file]: the location where the dumped XML should be stored, default is

/sdcard/window_dump.xml

events: prints out accessibility events until terminated


---FINISH DEBUG----


#2楼 @caihongw 哈哈,我要是看懂了我就回答你了,可是我看不懂

不要用uiautomatorHelpet类执行测试了,直接用原生的方法试试,看下log就知道了!

—— 来自TesterHome官方 安卓客户端

  1. 麻烦使用下 markdown 的代码块吧,现在正文真心乱。。。
  2. 看了下 UiAutomatorHelper 的 github 仓库,两年没更新了,现在能不能用这个我表示比较担忧。建议你还是用原生的方法,把 jar 包 push 到收集然后 adb 命令行运行吧。

楼主你是不是第三方jar包里的方法找不到啊?

现在感觉2.0还是好用一点,用android studio直接编码调试运行,就不会有这些问题了

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up