Invocation Count

The number of times this method should be invoked.

Lets Create Java class

import org.testng.annotations.Test;
publicclassinvocationcountexample {
@Test(invocationCount = 10 )
publicvoid testMethod1() {
System.out.println("This is testMethod1");
}
@Test
publicvoid testMethod2() {
System.out.println("This is testMethod2");
}
}

TestNG.xml

<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEsuiteSYSTEM"http://testng.org/testng-1.0.dtd">
<suitename="Suite"parallel="none">
<testname="Test1">
<classes>
<classname="invocationcountexample"/>
</classes>
</test><!-- Test -->
</suite><!-- Suite -->

Results

image

Here, testMethod1 is executed 10 times because we are using invocationCountas 10 and for testMethod2 will executed only one time.

Comments