安卓命令行测试

标签 android unit-testing

我正在尝试设置 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/

相关文章:

android - 对于 android API 级别不一致,如何获取编译时错误而不是 NoSuchMethodError 运行时错误?

android - 找不到 TextInput 功能文档?

angular - 如何从单元测试访问注入(inject)的 ngControl?

javascript - sinon模拟不接听电话

java - 如何手动设置 gradle-2.2.1-all.zip

swift - 如何测试异步方法的结果?

c++ - 如何设置要运行的 Boost 单元测试

java - 在设备 < Android M 上找不到类 'org.simpleframework.xml.core.Persister'

android - 单击回调后的新 Intent

android - 在 RxKotlin 中处理执行器