提供可靠的方式来报告多线程和并行测试的输出

作者: joffrey-bion创建于 2025年2月17日更新于 2026年9月15日
标签theme: programming modelstatus: team discussiontheme: reportingcomponent: Jupitercomponent: Platformtype: new feature

TL;DR: 我建议: 1. 添加一个 API 来报告使用 TestReporter 的测试中的 stdout 和 stderr,与 publishEntry("stdout", "...") 不同。例如,提供类似 TestReporter.outTestReporter.errPrintStream,这样测试作者就可以使用 TestReporter.out.println("...") 而不是 System.out.println()。 2. 在 TestExecutionListener 中添加一个回调,以获取来自这些新流的流式输出(如 https://GitHub.com/junit-team/junit5/issues/4317 中所提议的),或者可能是其他报告键(与 stdout/stderr 不同),以在 reportingEntryPublished 中获取此输出。 __________

目前,JUnit 不能识别除了原始测试线程以外的其他线程的输出,或者至少不能将其归属于其源自的测试。正如我们在文档中看到的 在文档中:

内容来源: junit-team/junit-framework