在测试阶段生成 html Surefire 测试 html 输出
我不确定这是否是一个简单的问题,但我希望 Surefire 在测试阶段生成 html 格式的输出文件(除了 xml 和 txt 格式的输出文件)。
我试图通过为 build>surefire 添加“执行”条目来实现这一点。这是正确的位置吗?如果是这样,我做错了吗?
<build>
..
<plugins>
..
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.6</version>
<configuration>
<outputDirectory>site</outputDirectory>
</configuration>
<executions>
<execution>
<id>during-tests</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
I'm not sure if this is a simple question or not, but I'd like surefire to generate html formatted output files(in addition to the xml and txt formatted output files) during the test phase.
I've tried to make this happen by adding an 'executions' entry for build>surefire. Is this the correct location for this? If so, am I doing it wrong?
<build>
..
<plugins>
..
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.6</version>
<configuration>
<outputDirectory>site</outputDirectory>
</configuration>
<executions>
<execution>
<id>during-tests</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法(不运行
site
)可能只是调用:这将在生成报告之前运行测试(但结果不是很好,因为不会生成 CSS,您必须为此运行
site
)。如果您确实想将
surefire-report
插件绑定到test
阶段,我的建议是使用report-only
目标(因为它不会重新运行测试,请参阅 SUREFIRE-257),如下所示:旁注,生成报告作为站点的一部分:
并且运行
似乎并没有那么慢(我使用的是 Maven 3,仅包含此报告)并且产生了更好的结果。如果您有一个复杂的站点设置,这可能不是一个选择(至少在不通过引入配置文件使事情变得更复杂的情况下)。
相关问题
The easiest way (without running
site
) would be probably to just invoke:This will run the tests prior to generating the report (but the result is not that nice because the CSS won't be generated, you'd have to run
site
for that).If you really want to bind the
surefire-report
plugin to thetest
phase, my suggestion would be to use thereport-only
goal (because it won't rerun the tests, see SUREFIRE-257), like this:As a side note, generating the report as part of the site:
And running
doesn't seem to be that much slower (I was using Maven 3, with this report only) and produces a much nicer result. This might not be an option if you have a complex site setup though (at least not without making things more complex by introducing profiles).
Related question