gpt4 book ai didi

java - 如何使用gradle在xml报告中发布其他junit5失败消息?

转载 作者:行者123 更新时间:2023-12-03 05:37:47 24 4
gpt4 key购买 nike

我试图将有关测试用例失败的其他信息添加到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
  • 最佳答案

    不,Gradle的报告基础结构不使用JUnit的LegacyXmlReportGeneratingListener

    此外,Gradle尚未在其生成的报告中包括报告条目。有关详细信息,请参见以下Gradle问题:https://github.com/gradle/gradle/issues/4605

    关于java - 如何使用gradle在xml报告中发布其他junit5失败消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54869768/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com