采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
[100%] /data/local/tmp/FirstU
看看tmp目录下有这个jar包吗
----adb push "F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi\bin\FirstUi.jar" /data/local/tmp/
----execCmd: adb push "F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi\bin\FirstUi.jar" /data/local/tmp/
[100%] /data/local/tmp/FirstU
这两个命令在命令行里单独执行下看看是不是正确
----execCmd: adb push "F:\eclipse\workspace\TetsUi\bin\FirstUi.jar" /storage/emulated/0/ [100%] /storage/emulated/0/FirstUi.jar ----runTest: adb shell uiautomator runtest FirstUi.jar --nohup -c com.imooc.UiTest.TestUi#testHome ----execCmd: adb shell uiautomator runtest FirstUi.jar --nohup -c com.imooc.UiTest.TestUi#testHome INSTRUMENTATION_STATUS: numtests=1 INSTRUMENTATION_STATUS: stream= com.imooc.UiTest.TestUi: INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner INSTRUMENTATION_STATUS: test=testHome INSTRUMENTATION_STATUS: class=com.imooc.UiTest.TestUi INSTRUMENTATION_STATUS: current=1 INSTRUMENTATION_STATUS_CODE: 1 INSTRUMENTATION_STATUS: numtests=1 INSTRUMENTATION_STATUS: stream= Failure in testHome: junit.framework.AssertionFailedError: Method "testHome" not found
Total time: 2 seconds ----jar包路径: "F:\JAVA1安装包\eclipse\eclipse\workspace\TetsUi\bin\FirstUi.jar" ----adb push "F:\JAVA1安装包\eclipse\eclipse\workspace\TetsUi\bin\FirstUi.jar" /storage/emulated/0/ ----execCmd: adb push "F:\JAVA1安装包\eclipse\eclipse\workspace\TetsUi\bin\FirstUi.jar" /storage/emulated/0/ [100%] /storage/emulated/0/FirstU ----runTest: adb shell uiautomator runtest FirstUi.jar --nohup -c com.imooc.UiTest.TestUi#testHome ----execCmd: adb shell uiautomator runtest FirstUi.jar --nohup -c com.imooc.UiTest.TestUi#testHome INSTRUMENTATION_STATUS: numtests=1 INSTRUMENTATION_STATUS: stream= com.imooc.UiTest.TestUi: INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner INSTRUMENTATION_STATUS: test=testHome INSTRUMENTATION_STATUS: class=com.imooc.UiTest.TestUi INSTRUMENTATION_STATUS: current=1 INSTRUMENTATION_STATUS_CODE: 1 INSTRUMENTATION_STATUS: numtests=1 INSTRUMENTATION_STATUS: stream= Failure in testHome: junit.framework.AssertionFailedError: Method "testHome" not found
-----------start--uiautomator--debug------------- ----工作空间: F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi ----execCmd: cmd /c android create uitest-project -n FirstUi -t 2 -p "F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi" Updated file F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi\build.xml ----------------------- --------修改build完成--------- ----execCmd: cmd /c ant Buildfile: F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi\build.xml -check-env: [checkenv] Android SDK Tools Revision 24.4.1 [checkenv] Installed at D:\android-sdk -build-setup: [getbuildtools] Using latest Build Tools: 24.0.2 [echo] Resolving Build Target for FirstUi... [getuitarget] Project Target: Android 7.0 [getuitarget] API level: 24 [echo] ---------- [echo] Creating output directories if needed... -pre-compile: compile: [javac] Compiling 1 source file to F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi\bin\classes [javac] 警告: [options] 源值1.5已过时, 将在未来所有发行版中删除 [javac] 警告: [options] 目标值1.5已过时, 将在未来所有发行版中删除 [javac] 警告: [options] 要隐藏有关已过时选项的警告, 请使用 -Xlint:-options。 [javac] 注: F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi\src\com\imooc\UiTest\TestUi.java使用或覆盖了已过时的 API。 [javac] 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。 [javac] 3 个警告 -post-compile: -dex: [dex] input: F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi\bin\classes [dex] Found Deleted Target File [dex] Converting compiled files and external libraries into F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi\bin\classes.dex... -post-dex: -jar: [jar] Building jar: F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi\bin\FirstUi.jar -post-jar: build: BUILD SUCCESSFUL Total time: 2 seconds ----jar包路径: "F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi\bin\FirstUi.jar" ----adb push "F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi\bin\FirstUi.jar" /data/local/tmp/ ----execCmd: adb push "F:\JAVA1安装包\eclipse_4.2.2_with_JRE_and_demo\eclipse\workspace\TetsUi\bin\FirstUi.jar" /data/local/tmp/ [100%] /data/local/tmp/FirstU ----runTest: adb shell uiautomator runtest FirstUi.jar --nohup -c com.imooc.UiTest.TestUi#testHome ----execCmd: adb shell uiautomator runtest FirstUi.jar --nohup -c com.imooc.UiTest.TestUi#testHome INSTRUMENTATION_STATUS: numtests=1 INSTRUMENTATION_STATUS: stream= com.imooc.UiTest.TestUi: INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner INSTRUMENTATION_STATUS: test=testHome INSTRUMENTATION_STATUS: class=com.imooc.UiTest.TestUi INSTRUMENTATION_STATUS: current=1 INSTRUMENTATION_STATUS_CODE: 1 INSTRUMENTATION_STATUS: numtests=1 INSTRUMENTATION_STATUS: stream= Failure in testHome: junit.framework.AssertionFailedError: Method "testHome" 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:257) INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner INSTRUMENTATION_STATUS: test=testHome INSTRUMENTATION_STATUS: class=com.imooc.UiTest.TestUi INSTRUMENTATION_STATUS: stack=junit.framework.AssertionFailedError: Method "testHome" 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:257) INSTRUMENTATION_STATUS: current=1 INSTRUMENTATION_STATUS_CODE: -2 INSTRUMENTATION_STATUS: stream= Test results for WatcherResultPrinter=.F Time: 0.105 FAILURES!!! Tests run: 1, Failures: 1, Errors: 0 INSTRUMENTATION_STATUS_CODE: -1 ******************* ---FINISH DEBUG---- *******************
package com.imooc.UiTest; import com.android.uiautomator.core.UiDevice; import com.android.uiautomator.testrunner.UiAutomatorTestCase; public class TestUi extends UiAutomatorTestCase { public void testHome() { UiDevice.getInstance().pressHome(); // TODO Auto-generated constructor stub } public static void main(String[] args) { String jarName="FirstUi"; String testClass="com.imooc.UiTest.TestUi"; String androidID="2"; String testname="testHome"; new UiAutomatorHelper(jarName,testClass,testname,androidID); } }