Generating Ant scripts to run tests or suites
You can generate Ant 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 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 Test Integrations and APIs.
Procedure
-
Select Generate External Tool Configuration from the
Tools menu.
The Generate External Tool Configuration wizard is displayed.
-
Complete the following steps in the Configuration type
and environment window of the Generate External
Tool Configuration wizard:
- Select ANT script for executing tests or suites.
- Select the Test Integrations and APIs environment from the list in which the selected resources are to be run.
- Click Next.
The Select resources window is displayed with the project resources tree.
-
Complete the following steps in the Select
resources window of the Generate External Tool
Configuration wizard:
-
Complete the following steps in the Ant script
options window of the Generate External Tool
Configuration wizard:
-
Complete the following steps in the Summary
window of the Generate External Tool
Configuration wizard:
An example of the Ant script that is generated by Test Integrations and APIs is as follows:
<?xml version="1.0" encoding="UTF-8"?> <project basedir="C:/Users/user/git/UATest_Sample/calculator" default="run-integrationtester"> <property name="install.dir" value="C:\Program Files\HCL\DevOpsTestAPI"/> <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="UATest" project="${basedir}/calculator.ghp" processStartupTimeout="60"> <Tests> <Test ref="calculator/Add/Test 1 plus 1 equals 2"/> </Tests> <AppProperties> <!-- <property name="example.system.property" value="exampleValue"/> --> </AppProperties> <AdditionalOptions> <!-- <option name="-overrideSlowFail" value="ON" /> --> </AdditionalOptions> </IntegrationTester> </target> </project>
Note: Starting from Test Integrations and APIs 9.1.1, the task definition is calledcom.ghc.ghTester.ant.RunTests
. In all the previous versions, it is known ascom.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 Test Integrations and APIs, 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 Test Integrations and APIs resource as an Ant task.
- On Windows™ systems, echo %errorlevel%
- On systems other than Windows™, echo $?