android - 使用 android instrumentation 在具有特定顺序的类的包上运行 Junit 测试

标签 android junit robotium

我正在尝试使用命令行运行 android instrumentation Junit 测试。我正在使用以下命令,它正在正确启动测试。

adb shell am instrument -w com.android.foo/android.test.InstrumentationTestRunner

我的android项目包有如下java源文件(按字母顺序排列)

com.android.foo

Activity 测试

联系人测试

启动测试

发送测试

当我使用上述命令运行测试时,测试首先开始执行 ActivityTest,依此类推。这不是我想要的,我希望它首先执行 LaunchTest,然后执行 ContactTest、SendTest 和 ActivityTest。我尝试使用

adb shell am instrument -w -e class com.android.foo.LaunchTest,com.android.foo.ContactTest com.android.foo/android.test.InstrumentationTestRunner

但它给我一个错误可能是因为我没有在我的代码中使用 TestCase 类,而是我的 LaunchTest 和其他人扩展了 ActivityInstrumentationTestCase2。

感谢任何帮助。

最佳答案

我终于使用以下命令让它工作了:

adb shell am instrument -e class com.android.foo.LaunchTest -w com.android.foo/android.test.InstrumentationTestRunner

关于android - 使用 android instrumentation 在具有特定顺序的类的包上运行 Junit 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7897134/

相关文章:

java - 安卓 : Share intent is not working for video file path

java - 字符串根本不起作用

java - Spring MVC 的 junit 测试用例

java - Junit 和 Hamcrest 的单元测试失败 - 无法将数据与两个列表对象进行比较

Java JUnit Eclipse 错误 : Type mismatch cannot convert from void to double

android - 将字符串数组传递给 Robotium 类

android - 我应该删除 onDestroyView 中的 OnClickListener 吗?

android - 在脚手架中,错误已显示为 "No value passed for parameter ' 内容'“- 我在下面附上了快照

android - 可以通过robotium在测试用例中打开/关闭wifi吗

Android JUnit 测试未在 Robotium 中检测到