使用Junit生成测试报告

时间:2016-09-12 04:27:04

标签: unit-testing logging junit reporting junit5

我想使用Junit进行日志记录和测试报告生成。记录到txt文件我可以使用java记录器实现。为了实现报告部分,截至Junit 4,没有这样的功能。我听说过Junit 5应该可以生成测试报告。根据他们使用Junit生成报告的经验,有人可以对此有所了解吗?

2 个答案:

答案 0 :(得分:0)

如果您的项目是maven base,那么为什么不尝试surefire插件。 doc here - http://maven.apache.org/surefire/maven-surefire-report-plugin/report-mojo.html

答案 1 :(得分:0)

正如我在How to create an HTML report for JUnit 5 tests?中提到的,JUnit Platform Gradle Plugin和ConsoleLauncher已经生成了JUnit 4样式的XML报告。

这是由XmlReportWriter使用的XmlReportsWritingListener完成的。后者只是TestExecutionListener的实现。

因此,如果您想生成自定义报告,您只需实施自己的TestExecutionListener,并从XmlReportWriterXmlReportsWritingListener中获取灵感。

此致

Sam( Core JUnit 5 committer

相关问题