java maven surefire 报告插件配置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1274523/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
maven surefire reporting plugin configuration
提问by Peter Delaney
I have a multi-module maven project. The parent pom.xml is simply a way to reference common information for the 4 subprojects. I have quite a few JUnit tests that run and I also have the Parent Project set up for Project WebSite using the maven-info-reports-plugin.
我有一个多模块 Maven 项目。父 pom.xml 只是引用 4 个子项目的公共信息的一种方式。我有很多运行的 JUnit 测试,我还使用maven-info-reports-plugin为 Project WebSite 设置了父项目。
I have the maven-surefire-report-pluginconfigured in the parent and it generates the target/site/surefire-report.htmlfile in each of the subprojects with the correct information.
我在父项目中配置了maven-surefire-report-plugin,它会在每个子项目中生成target/site/surefire-report.html文件,并提供正确的信息。
My problem is when I run my project website via site:runI do not see any of the surefire-report.htmlfiles in the Project website. The one that shows is in the target directory of the parent and it has no unit tests defined.
我的问题是当我通过site:run运行我的项目网站时,我在项目网站中看不到任何surefire-report.html文件。显示的是在父目录的目标目录中,它没有定义单元测试。
Is there a way I can configure maven-surefire-report-pluginor maven-info-reports-pluginto aggregate the subprojects generated surefire reports?
有没有办法可以配置maven-surefire-report-plugin或maven-info-reports-plugin来聚合子项目生成的 surefire 报告?
回答by Rich Seller
To elaborate on Seph's answer. You can set many of the Maven reports to aggregate results. To do this with the surefire-report plugin you'd do something like this:
详细说明Seph的回答。您可以设置许多 Maven 报告来聚合结果。要使用 surefire-report 插件执行此操作,您可以执行以下操作:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<aggregate>true</aggregate>
<!--also set this to link to generated source reports-->
<linkXRef>true</linkXRef>
</configuration>
</plugin>
</plugins>
</reporting>
Note the additional linkXRef property, this allows you to add cross-references to the generated html version of the source produced by the jxr plugin. The jxr plugin can also be set to aggregate, so the two combined allow you to browse your entire project structure.
请注意附加的 linkXRef 属性,这允许您向由jxr 插件生成的源代码的生成 html 版本添加交叉引用。jxr 插件也可以设置为聚合,因此两者结合可以让您浏览整个项目结构。
As far as I know, the maven-info-reports-plugin doesn't do aggregation.
据我所知, maven-info-reports-plugin 不做聚合。
回答by Seph
You can add
你可以加
<aggregate>true</aggregate>
to the surefire plugin in the parent pom.xml.
到父 pom.xml 中的 surefire 插件。
回答by smilyface
For command line
对于命令行
mvn surefire-report:report -Daggregate=true
It could be -
它可能是 -
mvn clean test -fn surefire-report:report -Daggregate=true
OR
mvn clean install -fn surefire-report:report -Daggregate=true
Note :
fn-> NEVER fail the build, regardless of project result
注意:
fn-> 永远不要使构建失败,无论项目结果如何
To add in pom
在 pom 中添加
<aggregate>true</aggregate>

