bash 从命令行运行 Android Junit 测试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11144466/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Running Android Junit tests from command line
提问by ZacAttack
I want to be able to run Junit tests from the command line, but when I run this command
我希望能够从命令行运行 Junit 测试,但是当我运行此命令时
java -cp /usr/share/java/junit.jar org.junit.runner.JUnitCore [test class name]
All I get back is
我得到的只是
OK (0 tests)
Does it have something to do with it being an Android project? I've run that command before and haven't had much issue.
它与它是一个Android项目有关系吗?我以前运行过该命令,但没有太大问题。
回答by andreea.sandu
回答by 0x8BADF00D
Template:
模板:
adb shell am instrument -w <YOUR_PACKGE_NAME>.test/android.support.test.runner.AndroidJUnitRunner
Example:
例子:
adb shell am instrument -w com.example.android.testing.blueprint.flavor2.test/android.support.test.runner.AndroidJUnitRunner
Details on Google's github page: Android Testing Blueprint
Google 的 github 页面上的详细信息:Android 测试蓝图

