Maven Surefire Reports

Applies to ReadyAPI 3.52, last modified on April 18, 2024

You can use the Maven Surefire Report plugin to convert the JUnit XML reports created by ReadyAPI to Surefire HTML reports.

This plugin was created by Apache Software Foundation. For more information about the plugin, see the Apache documentation.

In this topic, learn how to create a simple test that generates a Maven Surefire report.

Requirements

  • Make sure all the requirements for Maven tests are met.

  • Set the reports and outputFolder configuration properties to ${basedir}/target/surefire-reports to let the Surefire plugin locate them.

Start the test

To create a Surefire report, add the site argument to the command you use to start the test. For example:

C:/Work/MvnSample> mvn test site

Locate generated reports

The generated reports are saved in the <project-folder>/target/site folder.

This is a sample pom.xml file that runs a project and generates Surefire reports for it:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.smartbear.riaTest</groupId>
    <artifactId>RIA-Test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>RIA-Test</name>

   <repositories>
      <repository>
         <id>com.teamdev</id>
         <url>https://europe-maven.pkg.dev/jxbrowser/releases</url>
      </repository>
   </repositories>

    <!--Add the SmartBear ReadyAPI plugin repository.-->
    <!--Maven will download the plugin from the specified URL.-->
    <pluginRepositories>
        <pluginRepository>
            <id>SmartBearPluginRepository</id>
            <url>http://smartbearsoftware.com/repository/maven2/</url>
        </pluginRepository>
    </pluginRepositories>

    <build>
        <plugins>
            <plugin>
                <!--Plugin groupID used to uniquely identify the project with the plugin.-->
                <groupId>com.smartbear</groupId>
                
                <!--Plugin artifactId used to find the plugin in the project.-->
                <artifactId>ready-api-maven-plugin</artifactId>
                
                <!--Specifies your ReadyAPI version. Maven will use the appropriate plugin version.-->
                <!--IMPORTANT: Must be the same as your ReadyAPI version.-->
                <version>3.52.0</version>
                <executions>
                    <execution>
                        <!--Specifies the lifecycle phase to run ReadyAPI tests.-->
                        <!--We recommend using the test phase.-->
                        <phase>test</phase>
                        <goals>
                            <!--Do not change. Commands the Maven plugin to run a functional test.-->
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <!--Required. Specifies the path to the project to be executed.-->
                            <!--For composite projects, specify the folder that contains the project..-->
                            <projectFile>maven-readyapi-project.xml</projectFile>
                            
                            <!--Required for Maven Surefire reports. Must be true.-->
                            <!--Commands ReadyAPI to generate JUnit-style reports.-->
                            <junitReport>true</junitReport>
                            
                            <!--Required for reports. Specifies the format of the report.-->
                            <!--Possible values: PDF, XLS, HTML, RTF, CSV, TXT and XML.-->
                            <!--Only available with a Pro license.-->
                            <reports>${basedir}/target/surefire-reports</reports>
                            
                            <!--Required for Maven Surefire reports.-->
                            <!--Sets the output folder for reports where Surefire expects them.-->
                            <outputFolder>${basedir}/target/surefire-reports</outputFolder>
                            <readyApiProperties>
                                <property>
                                    <!--A folder with ReadyAPI executable files.-->
                                    <!-- Used to run a local installation of ReadyAPI.-->
                                    <name>soapui.home</name>
                                    <value>C:\Program Files\SmartBear\ReadyAPI-3.52.0\bin</value>
                                </property>                        
                            </readyApiProperties>
                        </configuration>    
                    </execution>
                </executions>
            </plugin>
            
        <!--Add Maven Site Plugin.-->
        <!--This plugin improves test stability and prepares test data for Maven Surefire.-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.5</version>
            <configuration>
               <locales>en</locales>
            </configuration>
         </plugin>            
        </plugins>
    </build>
    
    <!--Add Maven Surefire Plugin to generate JUnit XML reports.-->
    <reporting>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>2.19.1</version>
         </plugin>
      </plugins>
   </reporting>
   
   <!--Command the Site plugin to generate a web site.-->
   <distributionManagement>
        <site>
            <id>site.deployments</id>
            <name>Site deployments</name>
            <url>http://localhost/target/site</url>
        </site>
    </distributionManagement>
</project>

See Also

ReadyAPI Test Testing With Maven - Example
Maven Surefire Report Plugin Documentation

Highlight search results