Time Out
The maximum number of milliseconds this test should take.The “timeout” means if a test case is taking longer than a specified number of milliseconds to finish, TestNG will abort it and market it as failed.
Lets create a java file
import org.testng.annotations.Test;
publicclass timeoutexample {
@Test(timeOut = 5000) // time in mulliseconds
publicvoid testShouldPass() throws InterruptedException {
Thread.sleep(4000);
System.out.println("This test should pass");
}
@Test(timeOut = 1000)
publicvoidtestThisShouldFail() throws InterruptedException {
System.out.println("This test should through exception");
Thread.sleep(4000);
}
}
TestNG.xml
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEsuiteSYSTEM"http://testng.org/testng-1.0.dtd">
<suitename="Suite"parallel="none">
<testname="Test1">
<classes>
<classname="timeoutexample"/>
</classes>
</test><!-- Test -->
</suite><!—Suite -->
Results
Comments
Post a Comment