Running tests by using an Ant task

You can run tests by using the HCL DevOps Test Integrations and APIs (Test Integrations and APIs) Ant tasks.

You can create the Ant task in one of two ways:
To create a custom script, open a text file and define the Ant task, as in the following example:

  <taskdef classname="com.ghc.ghTester.ant.RunTests" name="IntegrationTester" classpathref="rittasklib">
 
Note: Starting from Test Integrations and APIs 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.
Here is an example of the syntax:
<?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>
The following table lists the attributes and child elements that can you can use to define an Ant task for running a test.
Table 1. List of available attributes and child elements
Attribute/Child element Description Required
Tests The full path (within the project) of the test resources <res_1>...<res_n> to be executed. Yes
AppProperties A collection of system properties to use during test execution. No
environment The name of the Test Integrations and APIs environment to use when the test items are executed. Yes
project The full path to the Test Integrations and APIs project file that contains the specified environment and test resources. Yes
resultsServerLogging The option for how the Results Server URL for executed items is written to the console. The following options are available:
ignore
The report URL is not written to the console.
absolute
The full URL is written to the console.
relative
A URL relative to the current Results Server location for the project is written to the console.
No, default is absolute
junitDir Indicates that JUnit reports should be generated for all suites being executed and that the reports should be placed in the specified folder. A full path to the folder is required. The path can include the ${basedir} variable to refer to the directory in which the ant script is running. For more information on the format of the output file, see JUnit style output. No, default is not to generate JUnit reports.
securityToken The value of the security token to use for authentication with HCL DevOps Test Virtualization Control Panel (Test Virtualization Control Panel) when domain security is enabled. For more information, see Domain level security. No, default is to send no token.
haltOnFailure If the Test Integrations and APIs Ant task fails, the Ant script will also fail when this flag is set to true.
Note: If you are executing Ant with -verbose or -debug and the flag is set to true, a failure will result in a Java exception stack being output.
No, default is false.
failureProperty The name of a property that is set in the event of a failure. No
AdditionalOptions A collection of options that are supported by the RunTests executable but are not defined as attributes of the Test Integrations and APIs Ant task. No 
option A child element within the AdditionalOptions element. Each option element includes the following attributes:
name
A RunTests command line argument, such as "-overrideSlowFail". For a complete list of these arguments, see Running tests by using the command line.
value
An optional value to be assigned to the argument.
No 
secrets Override secrets collection names defined by the environment. For more information, see Accessing Test Hub from IntegrationTesterCmd, ANT CLI, Maven CLI, or in a REST API call. No