Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven surefire reports in default lifecyle

How can i generate surefire reports in the maven's default lifecycle. We have jobs setup in teamcity with goals as

mvn clean install -Pprod

This job runs all the junits, i want to create HTML report of all the tests running in the project. I came across the sure-fire-reports plugin but it generates the report only in site phase it does not generates the report during the default clean install phase.

Can one please help how can i generate report default lifecycle

I tried including the surefire-reports plugin, in test phase as below but doesnot not works

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>report-only</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
like image 970
Ambuj Jauhari Avatar asked Oct 28 '25 11:10

Ambuj Jauhari


1 Answers

If you need the very report generated by maven-surefire-report-plugin, I see no other way than execute mvn site, because a report is executed only within the site phase of the build lifecycle.

Instead, if you just need an HTML-readable report, I'd suggest you this walk-around:

  • Take advantage of the XML files generated by the maven-surefire-plugin in the target/surefire-reports directory.
  • Code your own transformation sheet (XSL) to transform them to the desired HTML format.
  • In the pom, set a transformation in the next phase (for example, prepare-package) through the xml-maven-plugin.

If you put the XSL in the parent project and set this transformation in the parent pom, all the submodule projects should inherit it and produce the HTML reports during the corresponding build.

And last: How to browse the child HTML reports from the parent project? Hum... I'd say to code an Ant script to browse all the submodules and list the HTML files and produce an HTML index with them. This script should be executed only from the parent project.

like image 57
Little Santi Avatar answered Oct 30 '25 10:10

Little Santi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!