【问题标题】:Using adb shell command to test apps, how to make it continue even one of the test fails?使用 adb shell 命令测试应用程序,即使其中一项测试失败,如何使其继续?
【发布时间】:2017-06-11 12:39:21
【问题描述】:

我正在使用以下命令测试 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

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

【问题讨论】:

    标签: android unit-testing testing command-line adb


    【解决方案1】:

    如果你使用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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-15
      • 1970-01-01
      • 1970-01-01
      • 2014-12-19
      • 2016-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多