使用 adb shell 命令测试应用程序,如何使其继续,即使其中一个测试失败



我正在使用如下命令测试Android应用程序:

adb shell am instrument -w -e class net.mandaria.test.TippyTipperTest,net.mandaria.test.TippyTipperTest2,net.mandaria.test.TippyTipperTest3 net.mandaria.test/android.test.InstrumentationTestRunner

但是,当其中一个测试失败时,整个测试执行将停止。例如,如果第一个测试"net.mandaria.test.TippyTipperTest"失败,我得到以下输出:

net.mandaria.test.TippyTipperTest:INSTRUMENTATION_RESULT: shortMsg=junit.framework.AssertionFailedError
INSTRUMENTATION_RESULT: longMsg=junit.framework.AssertionFailedError: shows enter
INSTRUMENTATION_CODE: 0

我的问题是:如何让它继续运行所有测试,即使第一个测试失败?

如果您使用 AndroidJUnitRunner

$ adb shell am instrument -w -r   -e debug false -e class com.example.MyClass com.example.test/android.support.test.runner.AndroidJUnitRunner

如果某些测试失败,则结果打印在最后

...
FAILURES!!!
Tests run: 4,  Failures: 2

INSTRUMENTATION_CODE: -1

最新更新