Generating Ant scripts to run tests and suites

HCL OneTest™ API can generate scripts that can be used to run test resources automatically from within Ant, by using the IntegrationTester Ant task.

About this task

Procedure

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

    The Generate External Tool Configuration wizard is displayed.

  2. On the Configuration type and environment page, select ANT script for executing tests or suites. Select the existing HCL OneTest™ API environment in which the selected resources are to be run. Click Next.

    The Select resources page is displayed with the project resource tree.

  3. Select the tests or suites that are to be included in the script (use Ctrl or Shift to select multiple items). You can select the resources by name or by ID. The advantage of using names is that they are more easily recognizable. If you delete the resource from the project and create another one with the same name, the script will still work. If you choose to use IDs, you can rename or move the resource within the project and the script will still work.

    If one or more resources were selected in the Test Factory perspective, those resources are automatically selected. Click Next.

    The Ant script options page is displayed.

  4. Select the location to which the generated Ant script should refer:
    • The current installation directory of HCL OneTest™ API
    • The INTEGRATION_TESTER_AGENT_HOME variable
    • The INTEGRATION_TESTER_HOME variable
    Click Next.

    The Summary page is displayed with the contents of the script.

  5. View the generated script. Select a location and name for the generated script and click Save to save the file.
    Note: If the file name you select is already in use, HCL OneTest™ API does not overwrite an existing file. You can use a modified file name, or you can cancel and enter a new name.
    Following is an example Ant script generated by HCL OneTest™ API:
    <?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 HCL OneTest™ API version 9.1.1.1, the task definition is called com.ghc.ghTester.ant.RunTests. In all the previous versions, it was com.ghc.ghTester.ant.GHTester.

    The script would be run in Ant like any other build script. If you use JMS or JDBC items in HCL OneTest™ API, 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 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>
  6. Click Finish.

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