我正在尝试根据 tutorial 在 android 平台上运行单元测试.比如说,我想为电子邮件应用程序运行测试。我打开/apps/Email/tests/AndroidManifest.xml
文件,查找 <manifest>
元素,然后查看 package
属性,即 com.android.email.tests
,并在 <instrumentation>
元素我看android:name
属性,即 android.test.InstrumentationTestRunner
.现在我打开控制台,然后运行
$ . build/envsetup.sh
$ lunch 1
$ adb shell am instrument -w com.android.email.tests/android.test.InstrumentationTestRunner
但是失败了:
INSTRUMENTATION_STATUS: id=ActivityManagerService
android.util.AndroidException: INSTRUMENTATION_FAILED: com.android.email.tests/android.test.InstrumentationTestRunner
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.android.email.tests/android.test.InstrumentationTestRunner}
那么..我做错了什么?
最佳答案
请运行 python development/testrunner/runtest.py 邮箱
然后你会看到它起作用了:)。
基本上你没有安装 com.android.email.tests 包。
你可以看到什么是可用于检测的
pm list instrumentation
你应该看到
instrumentation:com.android.email.tests/android.test.InstrumentationTestRunner (target=com.android.email)
在做的时候
pm list packages
package:com.android.email
package:com.android.email.tests
关于android - 从命令行运行 android 单元测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3299006/