Android的Robotium - 如何管理测试用例的执行顺序? [英] Android Robotium - How to manage the execution order of testcases?

查看:341
本文介绍了Android的Robotium - 如何管理测试用例的执行顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Robotium自动化应用程序的测试。 测试案例记录在案,他们都应该是测试在特定的顺序。但似乎 Junit的运行按字母顺序排列测试..我怎么重新排列顺序执行的?下面是我的测试类的基本结构:

 公共类ETTerminalTest扩展ActivityInstrumentationTestCase2< IdleActivity> {
   私人独奏独唱;
   私有静态最后记录仪记录仪= LoggerFactory.getLogger(ETTerminalTest.class);

   公共ETTerminalTest(){
       超(com.employtouch.etterminal.ui.activity,IdleActivity.class);
   }

   保护无效设置()抛出异常{
       独奏=新梭罗(getInstrumentation(),getActivity());
   }

   @抽烟
   公共无效testEnterPin()抛出异常{
       ...
   }

   @抽烟
   公共无效testWhatEver()抛出异常{
       ...
   }
   @抽烟
   公共无效testSomethingElse()抛出异常{
       ...
   }
    @覆盖
    公共无效的teardown()抛出异常{
        尝试 {
            // Robotium将完成所有已打开的活动
            solo.finalize();
        }赶上(的Throwable E){
                e.printStackTrace();
        }
        getActivity()完成()。
        super.tearDown();
    }
}
 

解决方案

我不知道的Robotium,但测试顺序正常的JUnit测试用例可以通过创建一个测试套件来管理。我想这应该在这种情况下是一样的好。(我还没有尝试过我自己)。一些信息这里

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();
    } 
}

解决方案

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.

这篇关于Android的Robotium - 如何管理测试用例的执行顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆