从命令行运行android单元测试? [英] Running android unit tests from the command line?
问题描述
我正在尝试根据教程来在android平台上运行单元测试.举例来说,我要为电子邮件应用程序运行测试.我打开/apps/Email/tests/AndroidManifest.xml
文件,查找< manifest>
元素,然后查看 package
属性,它是 com.android.email.tests
,然后在< instrumentation>
元素中,查看 android:name
属性,是 android.test.InstrumentationTestRunner
.现在,我打开控制台,然后运行
I'm trying to run unit tests on the android platform in accordance with tutorial. Say, for example, I want to run tests for Email application. I open /apps/Email/tests/AndroidManifest.xml
file, look for the <manifest>
element, and look at the package
attribute, which is com.android.email.tests
, and in the <instrumentation>
element I look at the android:name
attribute, which is android.test.InstrumentationTestRunner
. Now I open the console, and run
$ . 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}
所以..我在做什么错了?
So.. What am I doing wrong?
推荐答案
请运行python development/testrunner/runtest.py电子邮件
Please run python development/testrunner/runtest.py email
然后您将看到它起作用:).
and then you will see it works :).
基本上您没有安装com.android.email.tests软件包.
Basically you do not have com.android.email.tests package installed.
您可以看到可用于检测的内容
You can see what is available for instrumentation
pm list instrumentation
你应该看到
instrumentation:com.android.email.tests/android.test.InstrumentationTestRunner(target = com.android.email)
instrumentation:com.android.email.tests/android.test.InstrumentationTestRunner (target=com.android.email)
在做
pm list packages
package:com.android.email
package:com.android.email
package:com.android.email.tests
package:com.android.email.tests
这篇关于从命令行运行android单元测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!