Running component tests from an Ant script

You can run component test launch configurations in a "headless" workbench (with no user interface for the development environment). This can be useful if you want to include component tests in an Ant script.

Before running component tests in headless mode:
Note: You cannot run several headless workbenches on the same workspace at the same time, nor can you use a headless workbench while an Eclipse graphical user interface has locked the workspace.
To create and run an Ant script:
  1. Select File > New > File.
  2. Enter build.xml as the name of the Ant script and click Finish.
  3. Double-click the build.xml Ant script to open the Ant editor.
  4. Enter the following content in the editor:
    <?xml version="1.0" encoding="UTF-8">
    <project name="MyTestProject" default="ComponentTestHeadless" >
    
    	<target name="ComponentTestHeadless">
    
    		<property name="eclipse_dir" value="D:\\eclipse"/>
    		<property name="workspace_dir" value="D:\\workspace"/>
    		<property name="options" value=" -onlyClient ComponentTest -reportDirectory ${workspace_dir}\\batch_report -fullreport -timeStampMode"/>
    
    		<exec executable="${eclipse_dir}/jre/bin/java" dir="${eclipse_dir}" vmlauncher="false">
    			<arg line="-Xj9 -Dorg.eclipse.emf.ecore.EPackage.Registry.INSTANCE=org.eclipse.emf.ecore.impl.EPackageRegistryImpl -cp ${eclipse_dir}/startup.jar org.eclipse.core.launcher.Main -application com.ibm.r2a.command.line.mode.CommandLineModeApplication -data ${workspace_dir} ${options}" />
    		</exec>
    	</target>
    
    </project>
    Note: This is an example Ant script for Windows. For information on additional platform specific parameters, see the related reference topic for component test headless mode.
  5. Replace the property values of eclipse_dir and workspace_dir with the actual Eclipse installation directory and the workspace directory. Add any additional options to the options property value. Use double quotes when the path contains spaces and double backslashes (\\) instead of the backslash character. Here is an example: "C:\\Program Files\\IBM\\Rational\\".
  6. Close the Ant editor.
  7. To run the Ant script, right-click the build.xml script, select Run > External Tools > External Tools and click Run. This launches a new instance of the Eclipse environment in headless mode, which will run the component test launch configurations located in the specified workspace. You can also run the Ant script from a command line by using the runAnt command.
The results of the test execution are generated in a report directory located in the workspace.
Related concepts
Headless execution of component tests
Related reference
Component test headless mode reference
Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.