我正在尝试设置 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
我现在想运行生成的 Instrumentation 测试用例 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
如何运行测试?
最佳答案
你一定没有在你的设备上成功安装测试 apk。您可以通过执行 adb shell "pm list instrumentation"来检查。
关于安卓命令行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13522255/