[英]How to skip test if its taking time more than certain amount of time 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.我有 API 测试套件,其中很少有测试花费大量时间导致测试套件运行超过 5-6 小时。 Is there any way to skip certain tests which exceeds run time for that particular test in TestNG.有没有办法跳过某些超出 TestNG 中特定测试运行时间的测试。
First you implement IInvokeMethodListener
where you do:首先你在你做的地方实现IInvokeMethodListener
:
@Override
public void afterInvocation(IInvokedMethod method, ITestResult testResult){
if(testResult.getThrowable() instanceof ThreadTimeoutException){
testResult.setStatus(ITestResult.SKIP);
}
}
Say you implemented it in MyImpl
class.假设您在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
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.