我正在使用 Robotium 和 ActivityInstrumentationTestCase2 为 android 运行 UIAutomation。我有一个包含 5 个测试的测试套件。有时我的测试会因为测试开始而随机崩溃,而之前的测试尚未结束。有没有办法避免这种情况?是否可以在每次测试之前手动添加 10 秒延迟以摆脱这个可怕的恼人错误?
编辑:
public class MyTest<T extends RoboActivity> extends ActivityInstrumentationTestCase2<T>
{
protected Solo solo;
@Override
protected void setUp() throws Exception {
super.setUp();
solo = new Solo(getInstrumentation(), getActivity());
}
@Override
protected void tearDown() throws Exception {
solo.finishOpenedActivities();
try {
solo.finalize();
}
catch (Throwable e) {
Assert.fail(e.getMessage()+ e.toString());
e.printStackTrace();
}
super.tearDown();
}
}