Android Robotium - 如何管理测试用例的执行顺序?

发布于 2024-12-17 10:14:09 字数 1113 浏览 3 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我们只是彼此的过ke 2024-12-24 10:14:09

我不确定 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文