The Maven Surefire Plugin is the plugin that runs tests and generates 2 raw reports by default:
The Surefire Plugin is used during the
test phase of the build lifecycle to
execute the unit tests of an
application. It generates reports in 2
different file formats:
- Plain text files (*.txt)
- XML files (*.xml)
By default, these files are generated
at ${basedir}/target/surefire-reports
The plugin has some parameter allowing to tweak the reports a bit. From the surefire:test
mojo documentation:
disableXmlReport
: Flag to disable the generation of report files in xml format. Default value is: false.
reportFormat
: Selects the formatting for the test report to be generated. Can be set as brief or plain. Default value is: brief.
trimStackTrace
: Whether to trim the stack trace in the reports to just the lines within the test, or show the full trace. Default value is: true.
For an HTML format of the report, you can then use the Maven Surefire Report Plugin:
The Surefire Report Plugin parses the generated TEST-*.xml
files under ${basedir}/target/surefire-reports
and renders them to DOXIA which creates the web interface version of the test results.
You can either get the report generated as part of the site generation or by running the standalone surefire-report:report
goal. From the Usage page:
Generate the report as part of Project Reports
To generate the Surefire report as
part of the site generation, add the
following in the section
of your POM:
<project>
...
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</reporting>
...
</project>
When the mvn site
is invoked, the
report will be automatically included
in the Project Reports menu as shown
in the figure below.
Generate the report as standalone
The Surefire report can also generate
the report using its standalone goal:
mvn surefire-report:report
A HTML report should be generated in
${basedir}/target/site/surefire-report.html
.