2012-11-23 142 views
1

我正在尝试设置android测试框架。Android命令行测试

我在~/boldapp/BOLDApp/

一个项目,我决定我应该在~/boldapp/BOLDApp/tests必须通过的测试项目,如http://developer.android.com/tools/testing/testing_android.html#TestProjects

描述我做了以下按http://developer.android.com/tools/testing/testing_otheride.html

我跑android create test-project -m ../ -n BOLDAppTest -p tests

我现在想运行生成的仪器测试用例MainActivityTest.java

当运行ant run-tests,所建议的,我得到:

BUILD FAILED 
Target "run-tests" does not exist in the project "BOLDAppTest". 

当我备选地运行输出的ant test部分是:

test: 
    [echo] Running tests ... 
    [exec] INSTRUMENTATION_STATUS: id=ActivityManagerService 
    [exec] INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{au.edu.unimelb.boldapp.tests/android.test.InstrumentationTestRunner} 
    [exec] INSTRUMENTATION_STATUS_CODE: -1 
    [exec] android.util.AndroidException: INSTRUMENTATION_FAILED: 

我得到同样的错误,因为我运行时上述adb shell am instrument -w au.edu.unimelb.boldapp.tests/android.test.InstrumentationTestRunner

以及当我运行时:

adb shell am instrument -w au.edu.unimelb.boldapp/android.test.InstrumentationTestRunner

如何运行测试?

回答

2

你必须。没有安装测试apk在你的设备上成功。你可以通过执行adb shell“pm list instrumentation”来检查。

+0

当我运行adb shell pm列表工具时,我得不到输出。我没有意识到我需要一个设备。当我运行“蚂蚁艾玛调试安装测试”它的作品。 – oadams

+0

恭喜。但是,你知道艾玛意味着什么吗? –