Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

testng

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.

like image 924
Feixiong Liu Avatar asked Sep 30 '14 19:09

Feixiong Liu


People also ask

How do you run the same test case multiple times in Robot Framework?

For example, if you are running tests on the current folder, you can pass "." as many times as you want the test to run. Ex: robot -t "*My test*" . . . This command will run all tests that match the expression 3 times, and the report will contain all 3 executions and results.

Which annotation provide ability to run a test multiple times with different arguments?

Parameterized tests make it possible to run a test multiple times with different arguments. They are declared just like regular @Test methods but use the @ParameterizedTest annotation instead.


1 Answers

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.

like image 90
niharika_neo Avatar answered Sep 20 '22 07:09

niharika_neo