Applies to ReadyAPI 2.7, last modified on June 25, 2019

If you are using Maven in your development environment, you can include LoadUI tests in your builds. To do so, you command Maven to download and use the ReadyAPI Maven plugin in your project.

Requirements

To run LoadUI tests from Maven, you need to have the following on the computer, where you are going to run a Maven build:

You do not need to configure your environment specifically for running load tests, and any required dependencies will be handled by Maven.

Pom File

Maven reads details about the build from the pom.xml file. You need to configure it to get the ReadyAPI plugin from the Maven repository and add a load test to the test phase of the build lifecycle.

You can find a sample Maven configuration below. If you already have your own configuration, copy the necessary elements to it.

Running Load Test

To start the load test, use the Maven test command in the folder with your pom.xml file. This command will run the load test and generate reports for it. For example:

C:/Work/MvnSample> mvn test

If your tests use the Maven SureFire plugin to create reports, use the site command instead.

C:/Work/MvnSample> mvn site

Sample Maven Load Test

Below is a sample pom.xml file that runs the Baseline-load-test-project.xml project. You can find this project in the <ReadyAPI installation directory> folder. To use the sample:

  • (Optional) Start virtual service from the project. This step is not required, but having a running virtual service will provide meaningful results.

  • Create a new pom.xml file and copy the sample code to it. Make sure to specify the same version as the ReadyAPI version you have.

  • Place the Baseline-load-test-project.xml project file in the folder where the pom.xml file is located.

  • Run the Maven build by using the mvn site command as described above.

You can specify additional properties of the load test by removing comments on unused elements and entering the parameters.

If you already have a pom.xml file, copy the elements to it to include a load test in the build.

<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.mycompany.app</groupId>
   <artifactId>my-app</artifactId>
   <version>1.0</version>
   
   <!--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>1.6.1</version>

            <executions>
               <execution>

                  <!--Specifies the lifecycle phase to run load tests .-->
                  <!--We recommend using the test phase.-->
                  <phase>test</phase>
                  <goals>
                     <!--Do not change. Commands the Maven plugin to run a load test.-->
                     <goal>loadtest</goal>
                  </goals>

                  <configuration>

                     <!--Required. Specifies the path to the project to be executed.-->
                     <projectFile>Baseline-load-test-project.xml</projectFile>
                     <!--Required. Specifies the name of the load test to be run.-->
                     <loadTest>Baseline Load Test (Geocoding)</loadTest>
                     <!--Required for reports. Specifies the format of the report to be generated.-->
                     <!--Possible values: PDF, XLS, HTML, RTF, CSV, TXT and XML. --> <reportFormat>PDF</reportFormat>
                     <!--Required for Maven Surefire reports. Must be true. -->
                     <!--Commands LoadUI to generate JUnit-style reports.-->
                     <junitReport>true</junitReport>
                     <!--Required for> Maven Surefire reports. Must be as shown. -->
                     <!--Specifies the folder to store reports in. -->
                     <reports>${basedir}/target/surefire-reports</reports>

                     <!-- ========= Additional elements ============= -->

                     <!--If true, commands Maven to continue the test run even when an assertion triggers.-->
                     <!--testFailIgnore>true</testFailIgnore-->
                     <!--Specifies the number of virtual users to be simulated. -->
                     <!--Has no effect if the "Per Scenario" load distribution is used.-->
                     <!--users></users-->
                     <!--Specifies existing statistics groups to be included in the report.-->
                     <!--statistics></statistics-->
                     <!--Specifies limits for the test run. -->
                     <!--Syntax: <SECONDS>:<TARGETS>:<FAILURES> (for example, 60:0:200)-->
                     <!--Project-defined time limits override this value.-->
                     <!--limits></limits-->
                     <!--Specifies the .CSV file to export the statistics group to. Syntax: <FileName>=<StatGroupName>-->
                     <!--export></export-->
                     <!--Specifies if the runner terminates requests running at the moment the test is stopped.-->
                     <!--If true, ongoing requests will be canceled.-->
                     <!--Otherwise, the test will finish when all requests are completed.-->
                     <!--If not specified, project properties are used.-->
                     <!--abort></abort-->
                     <!--Specifies if the load is simulated from the local computer.-->
                     <!--If true, the local computer is used. If false, configured agents are used.-->
                     <!--If not specified, project properties are used.-->
                     <!--local></local-->
                     <!--Specifies the remote agents to be used for the test run. Syntax: -a<ip>[:<port>]=<scenario>) -->
                     <!--agents></agents-->
                     <!--Sets the output folder for reports.-->
                     <!--outputFolder></outputFolder-->
                     <!--Specifies a settings file to be used.-->
                     <!--settingsFile></settingsFile-->
                     <!--Specifies a password for the encrypted settings file.-->
                     <!--settingsPassword></settingsPassword-->
                     <!--Specifies a password for the encrypted project file-->
                     <!--projectPassword></projectPassword-->
                     <!--Specifies the value of a global property for the test run. Syntax: <variable>=<value>-->
                     <!--globalProperties></globalProperties-->
                     <!--Specifies the value of a project property for the test run. Syntax: <variable>=<value>-->
                     <!--projectProperties></projectProperties-->
                     <!--Provides access to ReadyAPI properties.-->
                     <!--readyApiProperties></readyApiProperties-->
                     <!--If true, ReadyAPI will not send usage statistics.-->
                     <!--optOutUsageStatistics></optOutUsageStatistics-->
                     <!--Specifies the environment to be used in the test run.-->
                     <!--environment></environment-->

                     <!-- ========= /Additional elements ============= -->

                  </configuration>
               </execution>
            </executions>
         </plugin>

   </build>

</project>

Information on Plugins Used

This example uses the Maven Surefire Plugin to generate JUnit XML reports and Maven Site Plugin to improve test stability. Depending on the changes to the plugins, you may need to change the pom.xml file. For additional information about configuring these plugins, see their documentation.

See Also

SoapUI Testing With Maven - Example

Highlight search results