​
​
​
​
​
​
​
​
​
​
​
​
​
Invocation Count In TestNG
​
​
What Is Invocation Count In TestNG ?
​
If we want to run same test multiple times then the concept of invocation count comes which is an attribute of annotation.
Repeatedly tests can be executed with invocation count.
​
Syntax :
@Test(invocationCount=integernumber)
​
Example :
​
package testNGexamples;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
public class SimpleTest {
@Test(invocationCount=5)
//This is the Test
public void firstTest() {
System.out.println("First Test Is Executing ...");
}
@Test(invocationCount=5)
//This is the Test
public void secondTest() {
System.out.println("Second Test Is Executing ...");
}
@BeforeClass
//This will execute before class
public void beforeClass() {
System.out.println("Test starts :");
}
@AfterClass
//This will execute after class
public void afterClass() {
System.out.println("Test ends :");
}
}
Output :
​
[RemoteTestNG] detected TestNG version 7.4.0
Test starts :
First Test Is Executing ...
First Test Is Executing ...
First Test Is Executing ...
First Test Is Executing ...
First Test Is Executing ...
Second Test Is Executing ...
Second Test Is Executing ...
Second Test Is Executing ...
Second Test Is Executing ...
Second Test Is Executing ...
Test ends :
PASSED: firstTest
PASSED: secondTest
PASSED: secondTest
PASSED: secondTest
PASSED: firstTest
PASSED: firstTest
PASSED: firstTest
PASSED: secondTest
PASSED: firstTest
PASSED: secondTest
===============================================
Default test
Tests run: 2, Failures: 0, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 10, Passes: 10, Failures: 0, Skips: 0
===============================================
​
​
​
​
Refer next page Listeners In TestNG
​
​
​
​