[英]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.