测试报告断言并继续测试
Testng report assert and continue test
我正在尝试使用 fluentlenium 进行测试,并将其报告给范围报告。
问题是我在整个测试过程中都有断言,并且想在不使用 try 和 catch 的情况下报告它们。
有什么办法吗?有没有断言侦听器之类的?
您可以自己使用 SoftAssert
的工具 IAssert
我做这样的事情(我在每次断言失败时截屏)是像这样包装 SoftAssert class:
import org.testng.asserts.IAssert;
public class SoftAssert extends org.testng.asserts.SoftAssert {
@Override
public void onAssertFailure(IAssert<?> assertCommand, AssertionError ex) {
LOGGER.log(Level.FATAL, assertCommand.getMessage());
//doReportingStuffHere
super.onAssertFailure(assertCommand, ex);
}
}
现在每次你的软断言失败时(当它发生时,不仅仅是在最后)你可以做你的报告。
我正在尝试使用 fluentlenium 进行测试,并将其报告给范围报告。
问题是我在整个测试过程中都有断言,并且想在不使用 try 和 catch 的情况下报告它们。
有什么办法吗?有没有断言侦听器之类的?
您可以自己使用 SoftAssert
的工具 IAssert
我做这样的事情(我在每次断言失败时截屏)是像这样包装 SoftAssert class:
import org.testng.asserts.IAssert;
public class SoftAssert extends org.testng.asserts.SoftAssert {
@Override
public void onAssertFailure(IAssert<?> assertCommand, AssertionError ex) {
LOGGER.log(Level.FATAL, assertCommand.getMessage());
//doReportingStuffHere
super.onAssertFailure(assertCommand, ex);
}
}
现在每次你的软断言失败时(当它发生时,不仅仅是在最后)你可以做你的报告。