Designer > BPEL Unit Testing > Creating and Running a B-unit Ant Script

Creating and Running a B-unit Ant Script

Create individual B-unit test cases manually, or save each simulation path you run as a B-unit test file.
If you want to include B-unit testing in an automated build environment, you can create an Ant script to run all the B-unit tests and suites from multiple orchestration projects outside of Process Developer, on the command line. This capability is similar to using the command line BPRD script to deploy a BPR archive to the server.


You must install the B-Unit Ant Runtime component of the Process Developer before you can run the Ant script. The installation creates a directory containing the runtime files required to run the B-unit Ant script from the command line, outside of Process Developer. You do not need to install Ant separately: the Apache Ant application is installed as part of Process Developer.
Note: Version 1.7.0 of Ant (or above) is required.

Creating a B-unit Ant Script

Use the following procedure to create a B-unit Ant script:
  1. 1. Ensure your orchestration projects contains one or more B-unit tests or suites, as described in Creating a BPEL Unit Test File.
  2. 2. Select one B-unit test or suite and right mouse-click to select New > BUnit Ant Script.
  3. 3. In the Export B-unit Ant Script wizard, select a folder, such as the test folder, and enter a filename. Select Next.
  4. 4. Select the B-unit tests and suites to include. You can select multiple tests from multiple projects. Also, after you create the script, you can edit it to add more folders of tests.
  5. 5. Select the B-unit options as desired:
  6. 6. Select Finish to generate the filename.ant.xml file.
The ant script opens in an editor for you to view or edit. Follow the instructions in the ant script to set the B-unit runtime classpath if you wish to execute this script outside of Process Developer.
You can create a code coverage report when you run a B-unit ant script on the command line. For details, see Generating a Code Coverage Report.

Notes on Modifying a B-Unit Ant Script

Within the ant script, you can override properties in the individual B-unit files.

Adding Multiple B-unit and B-suite to an Ant Script

Ant provides many ways to specify resource collections, such as a group of B-unit and B-suite files. One example is the following.
<fileset dir="${test.dir}" includes="**/*.bunit"/>
For examples, refer to the resource collections section of the Ant 1.7 (or later) documentation.

Running a B-Unit Ant Script

You can run the filename.ant.xml file from within Process Developer if desired. Right-mouse click on the file and select Run As > Ant Build. In the Console you can view trace and log details.
To run the Ant script on the command line, do the following:
  1. 1. Open a command window.
  2. 2. Navigate to the file system folder where the ant script is located.
  3. 3. At the command line prompt, type ant -f filename.ant.xml

Generating a Code Coverage Report

Using a B-unit ant script, you can generate a code coverage report. The report tracks execution paths and display which activities were executed, expressed as percentage of activities executed at least once, in relation to all process's activities.
To generate a code coverage report:
  1. 1. Create a B-unit ant script as described in Creating and Running a B-unit Ant Script.
  2. 2. In the <target> named instrument, remove the comments and fill in a resource collection of bpel files. The following example show a simple resource collection:
  3. <target depends="init" name="instrument">
    <!-- optional
    <coverage activitycoverage="true" linkcoverage="true" />
    <file name="../bpel/myFile.bpel"/>
    By default, a code coverage report is generated for activities. If you want to include links, add the optional <coverage> element.
  4. 3. In the target named test, uncomment the <engine properties> section.
  5. 4. In the target named coverage report, do the following:
  6. 5. Run the B-unit ant script on the command line to generate the report. For example, in a command window, type ant -f filename.ant.xml.
What the Code Coverage Report Shows
Adding Code Coverage to an Existing B-Unit Ant Script
If you have an existing B-unit ant script, you can add code coverage to it just by putting in the correct ant tasks in the B-unit ant script.