0
我正在使用Robotium在Android上执行自动化测试。 问题是,当执行一堆测试时,如果任何测试导致应用程序崩溃 - 将不会执行进一步的测试。 “只有这条信息会出现”测试未能运行到完成,原因:'由于'进程崩溃'导致测试运行失败。'。查看设备logcat以获取详细信息“。使用Robotium处理应用程序崩溃
我试着在runTest()上使用try \ catch,但应用程序崩溃时不会引发异常。
public void runTest() throws Throwable {
try {
super.runTest();
} catch (Throwable t) {
String testCaseName = String.format("%s.%s", getClass().getName(), getName());
solo.takeScreenshot(testCaseName);
Logging.w(Logging.TAG.Test, String.format("Captured screenshot for failed test: %s", testCaseName));
t.printStackTrace();
String out = "";
for (StackTraceElement s : t.getStackTrace()) {
out = out + s.toString() + "\n";
}
fail(t.getMessage() + "\n" + out);
}
}
但仍然存在“测试未能运行至完成...”消息,并且所有测试执行都停止。
当前测试失败是可以的,问题在于未执行下一个测试。有人解决了这个问题吗?有没有办法从测试中处理应用程序异常?
如果应用程序依赖于出口,它有时可以帮助用finish()替换System.exit(0)。 –