how to create a robotium testsuite?

后端 未结 3 1489
有刺的猬
有刺的猬 2021-01-21 03:49

with the code below, the tests are not executed in the order I\'d like. test_homescreen is executed before test_splashscreen.

I\'d like to specify the tests to run and t

3条回答
  •  太阳男子
    2021-01-21 04:36

    as we know robotium runs the test cases in alphabetical order. So, for better result we can have separate test cases for separate activities. Later on other test cases related to that activity could be kept in same package (keep separate package for separate activity). this will help in running the test cases of same activity together. For changing the order of test you can always play with alphabets while naming the test cases. eg: "testAddSplash" will run before "testHomeScreen".

    You can also use suite() method:

    public static final Test suite()
    { 
                    TestSuite testSuite = new TestSuite(); 
                    testSuite.addTest(new MyTestCase("test1")); 
                    testSuite.addTest(new MyTestCase("test2")); 
                    return testSuite; 
    } 
    

    Your test case musts have a no-arg constructor and a constructor with string parameter that looks like this.

    public MyTestCase(String name)
    { 
                setName(name); 
    } 
    

提交回复
热议问题