maven surefire reporting plugin configuration
Asked Answered
E

3

12

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.

I have the maven-surefire-report-plugin configured in the parent and it generates the target/site/surefire-report.html file in each of the subprojects with the correct information.

My problem is when I run my project website via site:run I do not see any of the surefire-report.html files in the Project website. The one that shows is in the target directory of the parent and it has no unit tests defined.

Is there a way I can configure maven-surefire-report-plugin or maven-info-reports-plugin to aggregate the subprojects generated surefire reports?

Enoch answered 13/8, 2009 at 20:56 Comment(0)
E
37

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:

<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.

As far as I know, the maven-info-reports-plugin doesn't do aggregation.

Erik answered 14/8, 2009 at 6:24 Comment(3)
Excellent that worked. Thank you very much you saved me a lot of investigative time. I love Stackoverflow.comEnoch
Don't forget to "Accept" the answer that solved your problem. This answer also helped me so I would like the poster to get proper credit.Alben
@PeterDelaney Even if quite late can you accept the answer of Rich?Naumann
H
3

You can add

<aggregate>true</aggregate>

to the surefire plugin in the parent pom.xml.

Humanity answered 14/8, 2009 at 0:30 Comment(0)
F
2

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

To add in pom

<aggregate>true</aggregate>
Farra answered 17/4, 2019 at 11:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.