android.test.InstrumentationTestRunner中的getAllTests和getTestSuite

时间:2010-10-11 10:37:49

标签: android testing instrumentation

我创建了一个扩展android.test.InstrumentationTestRunner的测试运行器。我正在寻找一种方法来定义一组测试,以便根据一组配置执行。

我以为我可以覆盖以下方法来返回我的自定义测试套件,但是,这些都没有被调用!只是想知道使用这些是什么:

public TestSuite getAllTests() public TestSuite getTestSuite()

任何线索?我可以用什么其他方法在运行时定义自定义测试套件?

感谢名单

1 个答案:

答案 0 :(得分:0)

我也不知道......另一个解决方案是定义自己的注释并注释要运行的测试。然后,您可以使用以下命令仅运行带有该注释的测试:

使用给定注释过滤测试运行到测试:adb shell am instrument -w -e annotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner

如果与其他选项一起使用,则生成的测试运行将包含两个选项的并集。例如“-e size large -e annotation com.android.foo.MyAnnotation”将仅运行包含LargeTest和“com.android.foo.MyAnnotation”注释的测试。

过滤测试运行到没有给定注释的测试:adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner