TestNG: How can I run same test case multiple times?

Feixiong Liu picture Feixiong Liu · Sep 30, 2014 · Viewed 75.3k times · Source

I want to run a test case multiple times. Is that configurable in the testng.xml? If I add a loop in the test method, then the results of each run will not be affected in the testng report.

Answer

niharika_neo picture niharika_neo · Oct 1, 2014

You cannot do it from the xml, but in the @Test annotation - you can add a invocationCount attribute with the number of times you want to run it. It would come out as those many tests run in the report.

eg.

@Test(invocationCount = 10)
public void testCount() {..}

You have missed closing curly bracket at the end, so a small correction.