Android Robotium - 如何管理测试用例的执行顺序?
我正在尝试使用 Robotium 来自动化应用程序的测试。 测试用例已记录,并且应该按特定顺序进行测试。但似乎 Junit 按字母顺序运行测试。如何重新排列执行顺序?这是我的测试类的基本结构:
public class ETTerminalTest extends ActivityInstrumentationTestCase2<IdleActivity> {
private Solo solo;
private static final Logger LOGGER = LoggerFactory.getLogger(ETTerminalTest.class);
public ETTerminalTest() {
super("com.employtouch.etterminal.ui.activity", IdleActivity.class);
}
protected void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}
@Smoke
public void testEnterPin() throws Exception {
...
}
@Smoke
public void testWhatEver() throws Exception {
...
}
@Smoke
public void testSomethingElse() throws Exception {
...
}
@Override
public void tearDown() throws Exception {
try {
//Robotium will finish all the activities that have been opened
solo.finalize();
} catch (Throwable e) {
e.printStackTrace();
}
getActivity().finish();
super.tearDown();
}
}
I am trying to use Robotium to automate the testing of an application.
The test cases were documented and they are supposed to be test in specific order. But it seems that
Junit run the tests in alphabetic order.. how do I rearrange the order of execution? Here is the basic structure of my test class:
public class ETTerminalTest extends ActivityInstrumentationTestCase2<IdleActivity> {
private Solo solo;
private static final Logger LOGGER = LoggerFactory.getLogger(ETTerminalTest.class);
public ETTerminalTest() {
super("com.employtouch.etterminal.ui.activity", IdleActivity.class);
}
protected void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}
@Smoke
public void testEnterPin() throws Exception {
...
}
@Smoke
public void testWhatEver() throws Exception {
...
}
@Smoke
public void testSomethingElse() throws Exception {
...
}
@Override
public void tearDown() throws Exception {
try {
//Robotium will finish all the activities that have been opened
solo.finalize();
} catch (Throwable e) {
e.printStackTrace();
}
getActivity().finish();
super.tearDown();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定 Robotium,但普通 jUnit 测试用例的测试顺序可以通过创建测试套件来管理。我想在这种情况下也应该是相同的。(我自己没有尝试过)。一些信息此处。
I am not sure for Robotium, but the test order for normal jUnit test cases can be managed by creating a test suite. I guess it should be same in this case as well.(I haven't tried it myself). Some info here.