前提:已写好测试用例
新建个测试套MyTestSuite管理你需要跑的测试用例,或者将相同功能的测试用例归纳到一个测试套中
package com.robotium.test.testsuite; import junit.framework.TestSuite; import com.qunar.test.Test2; import com.qunar.test.test; public class MyTestSuite { public static TestSuite getTestSuite(){ TestSuite suite = new TestSuite(); suite.addTestSuite(Test1.class); suite.addTestSuite(Test2.class); return suite; } }
然后新建个MyTestRunner 类运行测试套中的用例,这个类继承InstrumentationTestRunner
package com.robotium.test.testrunner; import junit.framework.TestSuite; import android.test.InstrumentationTestRunner; import com.robotium.test.testsuite.MyTestSuite; public class MyTestRunner extends InstrumentationTestRunner { public TestSuite getAllTests(){ TestSuite suite = new TestSuite(); suite.addTest(MyTestSuite.getTestSuite()); return suite; } }
时间: 2024-10-31 07:57:13