为什么UiAutomator执行中报错找不到这个method?

来源:6-3 UiAutomator的快速调试

wvguugvvc

2017-01-15

http://szimg.mukewang.com/587b1a7a0001d57513660768.jpg

写回答

8回答

城下秋草

2017-01-16

 换个短些的路径,从头重新执行一遍 


0
1
wvguugvvc
已经换了短的,机器里也有firstui.jar这个文件了
2017-01-16
共1条回复

城下秋草

2017-01-15

[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


这两个命令在命令行里单独执行下看看是不是正确


0
5
wvguugvvc
回复
城下秋草
终于正确push进去了,看来确实是路径太长。但是还是报找不到method的错。。。
2017-01-16
共5条回复

城下秋草

2017-01-15

main函数完整贴出来

0
0

秋枫1207

2017-03-04

解决没?我也遇到同样的问题

0
0

wvguugvvc

提问者

2017-01-16

----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


0
0

wvguugvvc

提问者

2017-01-16

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


0
0

wvguugvvc

提问者

2017-01-15

-----------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----
*******************
0
0

wvguugvvc

提问者

2017-01-15

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);
		
	}

}


0
0

Android自动化测试实战 Java篇主流工具,框架,脚本

Android测试工程师大逆转的必备技能课程

1362 学习 · 476 问题

查看课程