Ant must perform the following steps in the specified order to analyze your project with Jtest:
Before you run analysis or collect coverage information with Maven, ensure that the Jtest license is properly configured (see Setting the License). |
To perform static analysis on your code:
-listener
switch or configure the jtest:listener
task in your target.Build your project with Ant. Your command line may resemble the following:
ant -lib PATH/TO/jtest-ant-plugin.jar -listener com.parasoft.Listener myTarget |
The above example the Jtest Plugin for Ant is added to the command line, but you can deploy the JAR file in the Ant's lib directory (see Initial Setup).
By default, test sources are excluded from analysis. To analyze test code, disable the
excludeTestSources
option; see Jtest Goals Reference for Ant.
You can include unit test results in the Jtest report by running your tests with the jtest task and the dedicated Unit Tests
built-in test configuration:
Unit Tests
built-in test configuration-listener
switch or configure the jtest:listener
task in your target.Build your project with Ant. Your command line may resemble the following (the jtest.coverage.skip
option allows you to skip collecting coverage):
ant -lib PATH/TO/jtest-ant-plugin.jar -listener com.parasoft.Listener buildTestAnalyze -Djtest.coverage.skip=true |
You can collect coverage information during execution of unit tests by running your tests with the jtest and agent tasks and the dedicated Unit Tests
built-in test configuration:
Unit Tests
built-in test configuration-listener
switch or configure the jtest:listener
task in your target.Build your project with Ant. Your command line may resemble the following:
ant -lib PATH/TO/jtest-ant-plugin.jar -listener com.parasoft.Listener buildTestAnalyze |
agent
TaskCollecting coverage with the Java agent is the recommended way of collecting coverage data with Jtest. The agent task, which allows runtime bytecode instrumentation (without modification of .class files) must be configured in the appropriate target. The following example shows the build script with the required tasks configured in one target:
<project name="agent-sample" default="buildTestAnalyze" xmlns:jtest="antlib:com.parasoft.jtest.plugin.ant"> <!-- sources directory containing both tests and application source code. Usually these sources are not placed in one directory. --> <property name="sources" value="src"/> <!-- classes directory --> <property name="classes" value="bin"/> <target name="buildTestAnalyze"> <!-- compiling sources --> <javac srcdir="${sources}" destdir="${classes}"/> <!-- instrumenting bytecode --> <!-- run tests --> <jtest:agent> <!-- Following attributes will be set: haltonerror="no" haltonfailure="no" fork="yes" If agent task skipped nested task will be executed without any config changes. --> <junit> <!-- Formatter element will be set as following: <formatter type="xml"/> If different formatter type has been set it will get overridden. If formatter has been configured by classname it will be left as it is. --> <classpath> <pathelement location="${classes}"/> </classpath> <batchtest> <fileset dir="${classes}" includes="**/*Test.class"/> </batchtest> </junit> <coverage> <includes> <fileset dir="${classes}" /> </includes> <testIncludes> <include>**/*Test.class</include> </testIncludes> </coverage> </jtest:agent> <!-- analysis --> <jtest:jtest/> </target> </project> |
Jtest's coverage agent allows you to collect coverage data during manual or automated tests performed on a running application. See Application Coverage for information about collecting application coverage with Jtest.
You can disable collecting coverage in one of the following ways:
skip
parameter to skip collecting coverage (this will not disable Jtest execution).-D
option: -Djtest.skip=true
<property name="jtest.skip" value="true"/>
(make sure the subprojects inherit this property if the Jtest tasks were configured there).