Generating Ant scripts to run tests

Rational® Integration Tester can generate scripts that can be used to run test resources automatically from within Ant, by using the GHTester Ant task.

About this task

Procedure

  1. Select Generate ANT Script from the Tools menu.

    The project resource tree is displayed.

  2. Select the tests, suites, or stubs that are to be included in the script (use Ctrl or Shift to select multiple items) and click OK.
  3. When prompted, select a location and name for the build script and click Save to save the file.
    Note: If the file name you select is already in use, Rational Integration Tester does not overwrite an existing file. You can use a modified file name, or you can cancel and enter a new name.

    An example Ant script, generated by Rational Integration Tester, is shown below.

    <?xml version="1.0" encoding="UTF-8"?><project basedir="C:/Projects/MyProject" default="run-ghtester">
       <property name="install.dir" value="C:/Program Files/IBM/RationalIntegrationTester"/>
       <taskdef classname="com.ghc.ghTester.ant.GHTester" name="GHTester">
          <classpath>
             <fileset dir="C:/Program Files/IBM/IBMIMShared/plugins/">
                <include name="com.ghc.ghTester.ant*.jar"/>
             </fileset>
          </classpath>
       </taskdef>
       <target depends="version-check" name="run-ghtester">
          <GHTester environment="MyEnvironment" haltOnFailure="true" project="${basedir}\MyProject.ghp" resultsServerLogging="absolute">
             <Tests>
                <filelist dir="${basedir}">
                   <file name="MyProject/MakeBooking/BookingStub"/>
                   <file name="MyProject/MakeBooking/MakeBooking"/>
                   <file name="MyProject/MakeBooking/Empty Test"/>
                </filelist>
             </Tests>
             <AppProperties>
                <property name="greenhat.net.defaultnetworkdevice" value="\Device\NPF_{49ACBD55-A866-47E4-AD87-ECF3A7FE49AB}"/
             </AppProperties>
          </GHTester>
       </target>
       <target name="version-check">
          <condition property="${correct.version}">
             <available classname="org.apache.tools.ant.taskdefs.condition.AntVersion"/>
          </condition>
          <antcall target="supported-version"/>
       </target>
       <target name="supported-version" unless="${correct.version}">
          <fail message="Please install ant version 1.7.0 or higher"/>
       </target>
    </project>

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

    If your project is configured to use permissions, configure single sign-on (see Running and viewing test artifacts with 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

Checking the test status

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.

Feedback