我正在尝试使用命令行运行 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/