【发布时间】:2017-08-26 08:39:53
【问题描述】:
我的 gradle 项目使用 junit 5,我正在尝试让测试报告显示在我的构建服务器上。 XML 报告基本上看起来不错——它包含所有测试类和方法,但缺少测试方法中打印的 stdout/stderr。只有一些 CDATA 包含测试元数据。
@Test
void testToString() {
System.out.println("Hello world");
...
}
XML 报告:
<testcase name="testToString()" classname="com.my.company.PairsTest" time="0.008">
<system-out><![CDATA[
unique-id: [engine:junit-jupiter]/[class:com.my.company.PairsTest]/[method:testToString()]
display-name: testToString()
]]></system-out>
</testcase>
是否有设置告诉 gradle 插件捕获 stdout/stderr?我环顾了http://junit.org/junit5/docs/current/user-guide/#running-tests-build,但没有找到。
我正在使用org.junit.platform:junit-platform-gradle-plugin:1.0.0-M3 和org.junit.jupiter:junit-jupiter-{api,engine}:5.0.0-M3。
【问题讨论】:
-
当前未捕获到 stdout/stderr 的输出。您可以改用 TestReporter 吗? github.com/junit-team/junit5/blob/master/documentation/src/test/…
-
大部分 stdout/stderr 是由正在测试的代码生成的,因此它们将无法使用 TestReporter。
-
(返回太快)@MarcPhilipp 是否有计划支持在 junit 中捕获 stdout/stderr,或者我应该在某处提交功能建议或 PR? IMO 的输出对于理解 CI 服务器上的测试失败非常有用,尤其是。如果故障在本地无法重现。