TestNG有条件地运行测试多次

问题描述 投票:1回答:1

我想在Table.getTables()第一次返回应该包含20个项目的表的列表下运行2次(或多次)的测试,但是当第二次运行测试时,它将不返回任何项目。因此,我想检查它是否第一次运行,然后检查它是否有20个项目,如果它是第二次运行,我想检查它是否不包含任何项目。我认为invocationCount对我不起作用。请看下面。谢谢

Java 8和TestNG 6.14。


    //Run this test twice 
    @Test
    public void repeatTest() {
        List<String> tables = Table.getTables();
        //if it is 1st run then check this
        Assert.assertEquals(tables.size(), 20); 

        //if it is second run then check this 
        Assert.assertEquals(tables.size(), 0); 
    }

java unit-testing testing testng
1个回答
0
投票

您可以拨打两次:

© www.soinside.com 2019 - 2024. All rights reserved.