0

我尝试在 android 上进行自动化 gui 测试。我尝试按照本教程进行操作,但无法在我的设备或模拟器上运行测试。我在测试项目库中添加了 android.jar 和 uiautomator.jar 我试图在 API 17 模拟器和 API 15 设备上运行它 单元测试不是UiAutomatorTestCase像魅力一样的作品的子类

这是我的 logcat 输出:

06-03 18:13:55.657: W/dalvikvm(10816): Unable to resolve superclass of Lcom/compname/app/appname/test/GuiTests; (4)
    06-03 18:13:55.657: W/dalvikvm(10816): Link of class 'Lcom/edupad/app/itooch/test/GuiTests;' failed
    06-03 18:13:55.657: W/dalvikvm(10816): threadid=1: thread exiting with uncaught exception (group=0x40ef22d0)
    06-03 18:13:55.657: E/EmbeddedLogger(451): App crashed! Process: com.compname.app.appname
    06-03 18:13:55.657: E/AndroidRuntime(10816): FATAL EXCEPTION: main
    06-03 18:13:55.657: E/AndroidRuntime(10816): java.lang.RuntimeException: Exception thrown in onCreate() of ComponentInfo{com.compname.app.appname.test/android.test.InstrumentationTestRunner}: java.lang.RuntimeException: Could not find test class. Class: com.edupad.app.itooch.test.GuiTests
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4824)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.app.ActivityThread.access$1300(ActivityThread.java:151)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1401)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.os.Handler.dispatchMessage(Handler.java:99)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.os.Looper.loop(Looper.java:155)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.app.ActivityThread.main(ActivityThread.java:5493)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at java.lang.reflect.Method.invokeNative(Native Method)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at java.lang.reflect.Method.invoke(Method.java:511)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:795)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at dalvik.system.NativeStart.main(Native Method)
    06-03 18:13:55.657: E/AndroidRuntime(10816): Caused by: java.lang.RuntimeException: Could not find test class. Class: com.compname.app.appname.test.GuiTests
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.test.AndroidTestRunner.runFailed(AndroidTestRunner.java:254)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.test.AndroidTestRunner.loadTestClass(AndroidTestRunner.java:88)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.test.AndroidTestRunner.setTestClassName(AndroidTestRunner.java:49)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.test.suitebuilder.TestSuiteBuilder.addTestClassByName(TestSuiteBuilder.java:80)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.test.InstrumentationTestRunner.parseTestClass(InstrumentationTestRunner.java:444)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.test.InstrumentationTestRunner.parseTestClasses(InstrumentationTestRunner.java:425)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:370)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4821)
    06-03 18:13:55.657: E/AndroidRuntime(10816):    ... 10 more
    06-03 18:13:55.662: E/EmbeddedLogger(451): App crashed! Package: com.compname.app.appname v1 (1.0)
    06-03 18:13:55.662: E/EmbeddedLogger(451): Application Label: iTooch
    06-03 18:13:55.662: W/ActivityManager(451): Error in app com.compname.app.appname running instrumentation ComponentInfo{com.compname.app.appname.test/android.test.InstrumentationTestRunner}:
    06-03 18:13:55.662: W/ActivityManager(451):   java.lang.RuntimeException
    06-03 18:13:55.662: W/ActivityManager(451):   java.lang.RuntimeException: Could not find test class. Class: com.compname.app.appname.test.GuiTests

我的控制台输出

[2013-06-03 18:13:53 - appname-tests] Android Launch!
[2013-06-03 18:13:53 - appname-tests] adb is running normally.
[2013-06-03 18:13:53 - appname-tests] Performing android.test.InstrumentationTestRunner JUnit launch
[2013-06-03 18:13:54 - appname-tests] Application already deployed. No need to reinstall.
[2013-06-03 18:13:54 - appname-tests] Project dependency found, installing: itooch-android
[2013-06-03 18:13:55 - appname-android] Application already deployed. No need to reinstall.
[2013-06-03 18:13:55 - appname-tests] Launching instrumentation android.test.InstrumentationTestRunner on SH25LW113796
[2013-06-03 18:13:55 - appname-tests] Test run failed: Instrumentation run failed due to 'java.lang.RuntimeException'
4

1 回答 1

0

从 Eclipse 中使用 ui automator 似乎是不可能的。

从cli运行解决了这个问题。

于 2013-06-04T12:24:05.307 回答