testNG 预期异常、忽略测试、超时测试

通过@Test 注解的参数值实现如下的几种测试

一、通过 @Test(expectedExceptions=异常类名) 参数实现到达 预期指定的异常效果

1 @Test(expectedExceptions = ArithmeticException.class)
2 public void divisionWithException() {
3         int i = 5 / 0;
4     }

二、通过 @Test(enabled = false) 参数就可以将注解的方法忽略掉

三、通过@Test(timeOut = 1000) 来设置商户超时时间,超过设定的超时时间,TestNG将会中止它并将其标记为失败

原文地址:https://www.cnblogs.com/zddwork/p/11431203.html