om Shukla
om Shukla

Reputation: 61

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 ?

Upvotes: 5

Views: 768

Answers (2)

om Shukla
om Shukla

Reputation: 61

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
        }

Upvotes: 1

assylias
assylias

Reputation: 328825

You could extract the test in a method, then create a test method with a reasonably high invocation count. In that test method, compare the time with a variable holding the timestamp of the first run and if it has run for more than 20 minutes skip the test.

Upvotes: 0

Related Questions