Running the application and generating statistics in remote build environments

Using the Java™ tasks built into Ant, you can run Java applications and generate code coverage statistics (Java task, JUnit task, and so on).

About this task

To generate code coverage statistics from Ant, you must add three additional parameters to the Ant call.
  • <jvmarg value="&quot;${llc-jvm-arg-output}${coverageOutputFile}&quot;" />
  • <jvmarg value="&quot;${llc-jvm-arg-engine}&quot;" />
  • <jvmarg value="&quot;${llc-jvm-arg-jvmti}${probescriptFile}&quot;" />
The JVM argument parameters are described in the following table:
Property name Description
llc-jvm-arg-output This property is automatically defined in the file CodeCoverageProperties.xml or CodeCoverageProperties64.xml and it is not necessary for the user to set it.
llc-jvm-arg-engine This property is automatically defined in the file CodeCoverageProperties.xml or CodeCoverageProperties64.xml and it is not necessary for the user to set it.
llc-jvm-arg-jvmti This property is automatically defined in the file CodeCoverageProperties.xml or CodeCoverageProperties64.xml and it is not necessary for the user to set it.
coverageOutputFile This property is the output location of the coverage statistics file. It must be set as a property by the user before running. This property must be a file within the basedir and must have the ".coveragedata" extension.
probescriptFile This property is the path to the probescript file generated in the previous step. This property is used as input into the instrumentation engine.

Example

In the following example, a regular Java application is run with code coverage enabled by using the Java Ant task:
<property name="coverageOutputFile" value="D:\codecoverage\outputFile.coveragedata"/>
        <property name="probescriptFile" value="D:\codecoverage\myproject.probescript"/>
        <java classname="com.ibm.storeapp.models.Store" fork="true" newenvironment="true">
            <jvmarg value="&quot;${llc-jvm-arg-output}${coverageOutputFile}&quot;" />
            <jvmarg value="&quot;${llc-jvm-arg-engine}&quot;" />
            <jvmarg value="&quot;${llc-jvm-arg-jvmti}${probescriptFile}&quot;" />    

            <classpath>
                <pathelement path="${basedir}\StoreApp.jar" />
            </classpath>
        </java>
In the following example, a regular Java application is run with code coverage enabled by using the JUnit Ant task:
<property name="coverageOutputFile" value="D:\codecoverage\outputFile.coveragedata"/>
        <property name="probescriptFile" value="D:\codecoverage\myproject.probescript"/>
        <junit showoutput="true" fork="yes" newenvironment="true">
            <jvmarg value="&quot;${llc-jvm-arg-output}${coverageOutputFile}&quot;" />
            <jvmarg value="&quot;${llc-jvm-arg-engine}&quot;" />
            <jvmarg value="&quot;${llc-jvm-arg-jvmti}${probescriptFile}&quot;" />            

            <formatter type="xml" />
            <test name="com.ibm.storeapp.models.test.TestCustomer" outfile="TestCustomer" />

            <classpath>
                <pathelement path="${basedir}\StoreApp.jar" />
                <pathelement path="${junitJar}" />
            </classpath>
        </junit> 

What to do next

Optionally, generate HTML reports.

Feedback