[英]testSuccess method implementation for RunListener interface
我有一个扩展 RunListener 接口(JUnit 框架)的类,因此我将能够根据测试结果执行不同的操作。 我的问题是接口没有 testSuccess 方法。 (例如,来自 TestNG 框架的 ITestListener 有一个 onTestSuccess 方法)我应该在扩展 RunListener 的类中创建我自己的 testSuccess 方法还是我能做什么?
谢谢你
RunListener 类http://junit.sourceforge.net/javadoc/org/junit/runner/notification/RunListener.html实现示例https://memorynotfound.com/add-junit-listener-example/
我预计 RunListener 接口会有一个 testSuccess 方法,但它没有。
private static final Description FAILED = Description.createTestDescription("failed", "failed");
public void testFinished(Description description) throws Exception {
System.out.println("Finished test: " + description.getMethodName());
if (description.getChildren().contains(FAILED)) {
// action for test failed
} else {
// action for test success
}
}
public void testFailure(Failure failure) throws Exception {
System.out.println("Failed test: " + failure.getDescription().getMethodName());
// mark the test as being failed
failure.getDescription().addChild(FAILED);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.