I am having API test suite where few tests taking a great amount time causing test suite to run more than 5-6+ hrs. Is there any way to skip certain tests which exceeds run time for that particular test in TestNG.
I am having API test suite where few tests taking a great amount time causing test suite to run more than 5-6+ hrs. Is there any way to skip certain tests which exceeds run time for that particular test in TestNG.
First you implement IInvokeMethodListener where you do:
@Override
public void afterInvocation(IInvokedMethod method, ITestResult testResult){
if(testResult.getThrowable() instanceof ThreadTimeoutException){
testResult.setStatus(ITestResult.SKIP);
}
}
Say you implemented it in MyImpl class. Then you could have:
@Listeners({MyImpl.class})
public class MyTest {
@Test(timeOut = 1)
public void test(){
// Do long task that takes more than 1 ms
// The test will be skipped
}
}