Generating Ant scripts to run tests or suites

You can generate Ant scripts from IBM® Rational® Integration Tester by using the Integration Tester Test Execution plug-in. You can use the generated script to run test resources automatically from within Ant by using the IntegrationTester Ant task.

Before you begin

You must have created a project and that project is open in Rational® Integration Tester.

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 ANT script for executing tests or suites.
    2. Select the Rational® Integration Tester 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 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.

      The Ant script options page is displayed.

  4. Complete the following steps in the Ant script options window of the Generate External Tool Configuration wizard:
    1. Select an option from the following options that the generated ANT script can refer to during a test run:
      • The current installation directory of Rational® Integration Tester.
      • The INTEGRATION_TESTER_AGENT_HOME variable.
      • The INTEGRATION_TESTER_HOME variable.
      Note: In Rational® Integration Tester 10.2.2 or later, the environment variables INTEGRATION_TESTER_HOME and INTEGRATION_TESTER_AGENT_HOME are automatically created at the time of installing the product software.
    2. Click Next.

      The Summary window is displayed with a preview of the contents of the Ant script 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 for the Ant script.
    2. Enter a name for the file.
      Note: The project configuration file is saved as an XML file by default.
    3. Click Save.
    4. Click Finish.
    An example of the Ant script that is generated by Rational® Integration Tester is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
                  <project basedir="C:/Projects/ExampleProject" default="run-integrationtester">
    <property name="install.dir" value="C:/Program Files/IBM/RationalIntegrationTester"/>
     <taskdef classname="com.ghc.ghTester.ant.RunTests" name="IntegrationTester">
       <classpath>
         <fileset dir="${install.dir}/tools/Ant">
          <include name="*.jar"/> 
            </fileset>
          </classpath> 
         </taskdef>
       <target name="run-integrationtester">
     <IntegrationTester environment="env1" project="${basedir}/ExampleProject.ghp" processStartupTimeout="60">
      <Tests>
        <Test ref="Comp/Op/Test123"/>
          </Tests>
        <AppProperties>
          <!--
          <property name="example.system.property" value="exampleValue"/>
            -->
          </AppProperties>
        <AdditionalOptions>
        <!--  
        <option name="-overrideSlowFail" value="ON" />
          -->
         </AdditionalOptions>
      </IntegrationTester>
     </target>
     </project>
    Note: Starting from Rational® Integration Tester 9.1.1, the task definition is called com.ghc.ghTester.ant.RunTests. In all the previous versions, it is known as com.ghc.ghTester.ant.GHTester.

    The script would be run in Ant similar to any other build script. If you use JMS or JDBC items in Rational® Integration Tester, use the -lib argument to make the JNDI provider classes available on the main classpath.

    If your project is configured to use permissions, configure single sign-on (see External tools). If krb5.ini is not available in the Windows directory, you can manually add the following properties:

    
    <AppProperties>
       <property name="java.security.krb5.realm" value="REALM"/>
       <property name="java.security.krb5.kdc" value="KEY DIST CENTER"/>
       ...
    </AppProperties>
    

Results

The generated script is saved to an output file.

What to do next

You can use the Ant test script to run the selected Rational® Integration Tester resource as an Ant task.

After executing the script, you can check the test status by running the following commands:
  • On Windows systems, echo %errorlevel%
  • On systems other than Windows, echo $?
The return code 0 indicates that the test has passed and 1 indicates that the test has failed.