lundi 4 mai 2020

Can I have TestNG fail/skip if the DataProvider provides no test cases?

If my TestNG DataProvider has some logic in it, but then it results in an empty Object[][], I would like TestNG to count this as a failed test. I would prefer to not have to put logic in the DataProvider which checks that the Object[][].length > 0 since my package has many of these types of DataProviders. Is it possible to have TestNG mark myTest as Failed or at least Skipped?

@DataProvider(name = "emptyDataProvider")
public Object[][] emptyDataProvider() {
    // Some misc logic...
    return new Object[][] { };
} 

@Test(groups = {"beta"}, dataProvider = "emptyDataProvider")
public void myTest(final String param1) {  

    // some assertions
}

Aucun commentaire:

Enregistrer un commentaire