Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TestNG @Test(invocationCount = 20) to a Class with @Test(DataProvider="someList") to a Method

I have a TestNG test Suit for a JAVA Project and, In there I have a

@Test(DataProvider="ListOfObjects") annotated Method. Which provides method with around 20 rows of data.( Hence the method runs 20 times.) Now, I want to run this class for 2hrs (part of SOAK related test.) On average the Class takes around 10 mins for single run. So I am thinking or running the whole class for 12 times, and thus thinking of using @Test(invocationCount = 20) on the Class itself. Any Better Ideas ?

like image 396
om Shukla Avatar asked Nov 08 '22 15:11

om Shukla


1 Answers

Found an Embarrassingly simple solution: Repeating the whole Test Suit as follows

@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
        }
like image 177
om Shukla Avatar answered Nov 15 '22 11:11

om Shukla