Maven

Maven is a testing framework for Java.

Enabling XML Output

When a Maven project is tested with mvn test it does not automatically produce JUnit XML output. You can enable XML output with the Surefire plugin. To enable it, add the following to the plugins section of your pom.xml file.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>3.3.1</version>
</plugin>

and then run

mvn test

The output will be in the target/surefire-reports directory.

Test Suite Naming

You can change the output filename with the <reportsDirectory> property.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-report-plugin</artifactId>
  <version>3.3.1</version>
  <configuration>
    <reportsDirectory>coolthing</reportsDirectory>
  </configuration>
</plugin>

You can see a full list of configuration options here.

Further Information

See an example of running Maven inside of a GitHub action here.

Last updated