我有API测试套件,很少的测试花费大量的时间,导致测试套件运行超过5-6小时。是否有任何方法可以跳过某些超过TestNG中特定测试的运行时间的测试。
发布于 2022-09-15 09:10:58
首先,您需要在其中实现IInvokeMethodListener
:
@Override
public void afterInvocation(IInvokedMethod method, ITestResult testResult){
if(testResult.getThrowable() instanceof ThreadTimeoutException){
testResult.setStatus(ITestResult.SKIP);
}
}
假设您在MyImpl
类中实现了它。那你就可以:
@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
}
}
https://stackoverflow.com/questions/73726155
复制相似问题