版本:testng-6.8.8.jar
该测试运行绿色:
@Test(expectedExceptions = { NullPointerException.class })
public void shouldTestNGIgnoreAssertsAfterExceptionThrown() throws Exception {
String iAmNull = null;
int length = iAmNull.length();
assertEquals(0, 1);
}
任何配置文件或其他选项
在异常发生后继续并评估断言?
最佳答案
您必须重写测试。
例如:
@Test
public void shouldTestNGIgnoreAssertsAfterExceptionThrown() {
String iAmNull = null;
boolean hasNpe = false;
try {
int length = iAmNull.length();
} catch(NullPointerException npe) {
hasNpe = true;
}
assertTrue(hasNpe);
assertEquals(0, 1);
}
关于java - 在发生异常后评估断言?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32903199/