maven surefire报告插件配置

问题描述 投票:7回答:3

我有一个多模块maven项目。父pom.xml只是一种引用4个子项目的公共信息的方法。我运行了很多JUnit测试,并且还使用maven-info-reports-plugin为Project WebSite设置了父项目。

我在父级中配置了maven-surefire-report-plugin,它在每个子项目中生成具有正确信息的target / site / surefire-report.html文件。

我的问题是当我通过网站运行我的项目网站时:运行我没有在项目网站上看到任何surefire-report.html文件。显示的那个位于父目标目录中,并且没有定义单元测试。

有没有办法可以配置maven-surefire-report-plugin或maven-info-reports-plugin来汇总子项目生成的surefire报告?

java maven-2 surefire
3个回答
28
投票

详细说明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>

请注意附加的linkXRef属性,这允许您添加对jxr plugin生成的源生成的html版本的交叉引用。 jxr插件也可以设置为聚合,因此这两个组合允许您浏览整个项目结构。

据我所知,maven-info-reports-plugin不进行聚合。


2
投票

你可以加

<aggregate>true</aggregate>

到父pom.xml中的surefire插件。


0
投票

对于命令行 -

mvn surefire-report:report -Daggregate=true

它可能是 -

mvn clean test -fn surefire-report:report  -Daggregate=true
OR
mvn clean install -fn surefire-report:report  -Daggregate=true

注意:fn - >无论项目结果如何,都不会失败

© www.soinside.com 2019 - 2024. All rights reserved.