mardi 18 février 2020

TestNG run the test several times conditionally

I want to run the test below 2 times(or more) first time the Table.getTables() returns the list of tables which should contain 20 items, but when the tests runs second time it will not return any item. So, I want to check to see if it is first run then check to see if it has 20 items and if it is second run I want to check to see if it does not contain any item. I do not think invocationCount will work for me. Please see below. Thanks

Java 8 and 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); 
    }

Aucun commentaire:

Enregistrer un commentaire