将TestNG @Test(invocationCount = 20)应用于带有@Test(DataProvider="someList")的类中的方法

5
我有一个针对JAVA项目的TestNG测试套件,在其中我有一个使用@DataProvider="ListOfObjects"注释的方法。该方法提供了大约20行数据。(因此该方法运行20次)。现在,我想要运行这个类2小时(作为SOAK相关测试的一部分)。平均每次运行该类需要大约10分钟。所以我考虑将整个类运行12次,并因此考虑在类本身上使用@Test(invocationCount = 20)。有更好的想法吗?
2个回答

1
发现一个非常简单的解决方案: 重复整个测试套件如下
@Test
public void RepeatTestSuite() {
    long startTime = new Date().getTime();
    while(!isTestFinished(startTime)) {

          List<String> suites = new ArrayList<String>();
             suites.add("./SOAK_all41.xml"); //path of .xml file to be run-provide complete path

             TestNG tng = new TestNG();
             tng.setTestSuites(suites);

             tng.run(); //run test suite
        }

0
你可以将测试代码提取到一个方法中,然后创建一个具有相当高的调用次数的测试方法。在该测试方法中,将时间与保存第一次运行的时间戳的变量进行比较,如果已经运行了超过20分钟,则跳过测试。

我有超过10个这样的类,每个类中至少有3个这样的方法。这些方法是根据设备类型(IoT)进行划分的。我认为我无法在一个方法中提取测试。 - om Shukla

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接