【发布时间】:2019-08-17 09:54:19
【问题描述】:
是否有 maven 或 gradle 插件可以生成 html 报告,包括每个测试用例的日志输出(通过或失败)?
我尝试过使用 maven 的surefire,但它似乎没有提供这样的功能。
我有点喜欢你在 intellij 上导出的 html 测试报告。
【问题讨论】:
是否有 maven 或 gradle 插件可以生成 html 报告,包括每个测试用例的日志输出(通过或失败)?
我尝试过使用 maven 的surefire,但它似乎没有提供这样的功能。
我有点喜欢你在 intellij 上导出的 html 测试报告。
【问题讨论】:
在 maven 中,您可以像这样通过surefire-report 完成:
<project>
...
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
</plugins>
</reporting>
...
</project>
或者在命令行中:mvn surefire-report:report
使用 gradle,你可以这样做:
test {
reports {
html.enabled = true
}
}
为 gradle 提供参考:https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test:reports
编辑: 要包含来自 sys.out/sys.err 的日志,请在 pom surefire 插件大括号中执行此操作:
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
【讨论】: