Generating Maven scripts to run stubs, tests, or suites

You can generate Maven scripts from HCL DevOps Test Integrations and APIs (Test Integrations and APIs) by using the Integration Tester Test Execution plug-in. You can use the generated script to run stubs, tests, or suites in a Maven build.

Before you begin

You must have created a project and that project is open in Test Integrations and APIs.

Procedure

  1. Select Generate External Tool Configuration from the Tools menu.

    The Generate External Tool Configuration wizard is displayed.

  2. Complete the following steps in the Configuration type and environment window of the Generate External Tool Configuration wizard:
    1. Select Maven script for executing stubs, tests, or suites.
    2. Select the Test Integrations and APIs environment from the list in which the selected resources are to be run.
    3. Click Next.

    The Select resources window is displayed with the project resources tree.

  3. Complete the following steps in the Select resources window of the Generate External Tool Configuration wizard:
    1. Select the stubs, tests, or suites that you want to include in the project configuration.
      Note: You can select multiple items by pressing the Ctrl or Shift key and clicking the tests or suites.
    2. Select the way in which the resources are referred by clicking either Name or ID.

      The advantage of using names is that they are more easily recognizable. If you delete the resource from the project and create another resource with the same name, the script still works.

      If you choose to use IDs, you can rename or move the resource within the project, and the script still works.

      Note: If you selected one or more resources in the Test Factory perspective, those resources are automatically selected to be included in the project configuration.
    3. Click Next.
      • If you selected the stubs only to be included as the resources in the test, the Summary window is displayed. Go to Step 5.
      • If you selected any tests or suites, with or without any stubs as resources in the test, the Maven POM options window is displayed. Continue with Step 4.
  4. Complete the following steps in the Maven POM options window of the Generate External Tool Configuration wizard:
    1. Select an option from the following options for generating the script:
      • Select Use the minimal POM option to enable the Test Integrations and APIs Maven plug-in to start the selected stubs during the Maven pre-integration-test phase, run the integration tests during the Maven integration-test phase, and then stop the stubs previously started in the Maven post-integration-test phase.
      • Select Use the standard Maven Failsafe plugin wrapper option to enable Maven to use the standard Maven Failsafe plug-in. Maven uses this plug-in to run integration tests during the Maven integration-test phase. However, Maven uses the Test Integrations and APIs Maven plug-in to run the stubs during the Maven pre-integration test phase and stop them in the Maven post-integration test phase.

      For more information about the lifecycle phases, see the Apache Maven documentation.

    2. Click Next.

      The Summary window is displayed with a preview of the contents of the Maven project configuration file in the XML format.

  5. Complete the following steps in the Summary window of the Generate External Tool Configuration wizard:
    1. Click Browse to select a location.
    2. Enter a name for the file.
      Note: The project configuration file is saved as an XML file by default.
    3. Click Save.
      If a file already exists with the name that you provided, you can choose to perform any one of the following options:
      • To overwrite an existing file with the same name, click Yes in the Confirm dialog.
      • To create a new file, click No in the Confirm dialog box, enter a different name for the file, and then click Save.
    4. Click Finish.
      An example of the Maven project configuration generated by Test Integrations and APIs is as follows:
      <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/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <groupId>com.mycompany</groupId>
          <artifactId>it-plugin-samples</artifactId>
          <version>0.0.1-SNAPSHOT</version>
          
          <!-- 
          If the plugin artifacts referenced by the below version property were already installed in the local maven repository, 
          run the maven goal 'versions:update-property -Dproperty=it-plugin-version' to discover new version from RTCP repository 
          and update the version value.
          Otherwise, manually edit the property value derived from RTCP version (v9.1.1.1 or later) eg. 1.911.1 for RTCP v9.1.1.1, 
          1.920.0 for RTCP v9.2.0, ..
          -->    
          <properties>
              <it-plugin-version>1.1001.0</it-plugin-version>
          </properties>    
          
          <dependencies>
              <dependency>
                  <groupId>com.hcl.products.test.it</groupId>
                  <artifactId>it-plugin-boot</artifactId>
                  <version>${it-plugin-version}</version>
                  <scope>test</scope>
              </dependency>
          </dependencies>
          <build>
              <plugins>
                  <plugin>
                      <groupId>com.hcl.products.test.it</groupId>
                      <artifactId>it-plugin</artifactId>
                      <version>${it-plugin-version}</version>
                      <configuration>
                          <forkCount>0</forkCount>
                          <properties>
                              <property>
                                  <name>it_config_xml</name>
                                  <value>
                                      <![CDATA[
                                      <projects>
                                          <project file="C:\Users\<user>\git\MyProjects\calculator\calculator.ghp" environment="UATest" run="calculator/Add/Test 1 plus 1 equals 2;calculator/2+2=5"/>
                                      </projects>
                                      ]]>
                                  </value>
                              </property>
                          </properties>
                      </configuration>
                      <executions>
                          <execution>
                              <goals>
                                  <goal>start-stubs</goal>
                                  <goal>run-tests</goal>
                                  <goal>stop-stubs</goal>
                              </goals>
                          </execution>
                      </executions>
                  </plugin>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-failsafe-plugin</artifactId>
                      <version>2.20</version>
                      <executions>
                          <execution>
                              <goals>
                                  <goal>verify</goal>
                              </goals>
                          </execution>
                      </executions>
                  </plugin>
              </plugins>
          </build>
          <repositories>
              <repository>
                  <id>rtcp-site</id>
                  <url>https://localhost:5443/maven2</url>
              </repository>
          </repositories>
          <pluginRepositories>
              <pluginRepository>
                  <id>rtcp-site</id>
                  <url>https://localhost:5443/maven2</url>
              </pluginRepository>
          </pluginRepositories>
      </project>

Results

The generated script is saved to an output file.

What to do next

You can run the script in Maven similar to any other build script.