【发布时间】:2019-02-25 15:39:44
【问题描述】:
我正在尝试将有关测试用例失败的其他信息添加到 xml 报告中:
使用 gradle 参数构建测试
test {
useJUnitPlatform()
reports.junitXml.enabled = true
// is it gradle side or junit side xml report generator implementation?
// (does it use LegacyXmlReportGeneratingListener?)
}
然后实现自己的扩展并由@ExtendWith(MyExtension.class)使用它
public class MyExtension implements TestExecutionExceptionHandler {
@Override
public void handleTestExecutionException(final ExtensionContext context, Throwable throwable) throws Throwable {
context.publishReportEntry("ADDITIONAL_INFORMATIONS", SOME_DATA);
// (is this call reportingEntryPublished from LegacyXmlReportGeneratingListener?)
throw throwable;
}
}
但 ADDITIONAL_INFORMATIONS 不会显示在 xml 中的任何位置。
我知道有org.junit.platform.reporting.legacy.xml.LegacyXmlReportGeneratingListener,但我只找到了org.junit.platform.launcher.Launcher 用例,没有关于如何将它与Gradle 一起使用。
使用 gradle/junit5 向 xml 失败条目添加附加消息的最佳方法是什么?
我可以使用 gradle 添加自己的 org.junit.platform.launcher.TestExecutionListener 吗?
我期待它<failure message="...here">。
使用
- junit 5.4.0
- gradle 4.10.2
【问题讨论】: