In this guide:
This guide is intended to help you collect coverage information for applications developed with .NET framework or Java technology.
The primary audience for this user guide are people responsible for ensuring compliance with your organization's policy regarding the application coverage level, including QA Engineers, developers, and build masters.
We assume that you are familiar with Parasoft technologies and have already deployed and licensed the following products:
The following options must be configured in the .properties file where you configure your dotTEST or Jtest settings to ensure that coverage data is correctly displayed on DTP:
report.coverage.images
- Specifies a set of tags that are used to create coverage images in DTP. A coverage image is a unique identifier for aggregating coverage data from runs with the same build ID. DTP supports up to three coverage images per report.session.tag
- Specifies a unique identifier for the test run and is used to distinguish different runs on the same build.build.id
- Specifies a build identifier used to label results. It may be unique for each build, but it may also label several test sessions executed during a specified build.The static coverage file must be generated on the build machine that contains the source code. The name of the file is static_coverage.xml.
Run the following test configuration on the solution:
dottestcli.exe -config "builtin://Collect Static Coverage" -solution SOLUTION_PATH |
The location of the static_coverage.xml file will be printed to the console.
The static coverage file is included in the monitor.zip package generated by the Jtest Plugin for Maven, Gradle, or Ant during the build process.
monitor
task or goal to your build command and execute the command in the AUT's main directory to generate the monitor.zip package. The location of the package will be printed to the console.Maven
mvn package jtest:monitor |
Gradle
gradle assemble jtest-monitor -I [INSTALL]/integration/gradle/init.gradle |
Ant
ant -lib [INSTALL]/integration/ant/jtest-ant-plugin.jar -listener com.parasoft.Listener jtest-monitor |
Ant requires all classes to be compiled before the monitor task is executed. Modify your project prior to the build and configure the task to ensure the correct sequence. The following example shows how the target can be configured:
|
Attaching the Coverage Agent to the AUT allows you enable collecting dynamic (runtime) coverage.
To attach the Coverage Agent to the AUT, you need to launch the IIS Manager tool shipped with dotTEST on the machine where IIS is installed and the AUT is deployed.
Invoke the following command to launch the IIS Manager tool:
dottest_iismanager.exe |
Go to the following address to check the status of the coverage agent: http://host:8050/status
. If the Coverage Agent is attached, you should receive the following response:
{"session":null,"test":null} |
To attach the Coverage Agent to the AUT, you need to add Jtest's -javaagen
t VM argument to the startup script of the server where the AUT is deployed.
Run the agent.sh/agent.bat script to print the Jtest Java agent VM argument to the console:
Jtest Agent VM argument: -javaagent:"[path to agent dir]\agent.jar"=settings="[path to agent properties file]\agent.properties",runtimeData="[path to monitor dir]\monitor\ runtime_coverage" |
-javaagent
argument to the application server’s startup script.Go to the following address to check the status of the coverage agent: http://host:8050/status
. If the Coverage Agent is attached, you should receive the following response:
{"test":null,"session":null,"testCase":null} |
You can connect to either CAM or SOAtest to the Coverage Agent. CAM provides an interface for starting and stopping test sessions during manual test execution. Connecting SOAtest enables you to collect application coverage during automated functional test execution.
Open CAM in a browser:
http://[your-Tomcat-host:port]/cam. |
The connection to the coverage agent is handled through a SOAtest test configuration.
In the next step, you will execute your tests using the new test configuration from the command line. But in order for DTP to associated the test results with the coverage information, you will need to create a properties file and specify the build ID used to create the static coverage file. The simplest way is to export the properties referenced by the SOAtest desktop.
report.coverage.images
- Specifies a set of tags that are used to create coverage images in DTP. A coverage image is a unique identifier for aggregating coverage data from runs with the same build ID. DTP supports up to three coverage images per report.session.tag
- Specifies a unique identifier for the test run and is used to distinguish different runs on the same build.build.id
- Specifies a build identifier used to label results. It may be unique for each build, but it may also label several test sessions executed during a specified build.Parasoft provides several ways to execute tests. You can execute tests manually or automate test scenario execution using the command line interfaces. In this guide, we will demonstrate executing manual test scenarios with CAM. We will also describe automated test execution with SOAtest.
To collect coverage data, you need to start a session. Only one tests session can be in progress at a time.
Run the soatestcli and using test configuration created in the previous step. You will also need to include the workspace, test assets (.tst files), and properties file. The -report
flag is optional, but specifying an easy-to-remember location may be helpful as you become familiar with the application coverage workflow:
./soatestcli -config "/path/to/your/test-configuration/app-cov.properties" -data "/path/to/your/workspace" -resource "/path/to/your/tests/your_tests.tst" -localsettings "/path/to/your/localsettings/file/soatest-app-cov.properties" -report "/directory/to/save/report/" |
Upload the report.xml file you downloaded from CAM to DTP. If you used SOAtest to execute your tests, the report will be saved in the location specified with the -report
flag. If you did not specify a location for the report, the file will be saved to the working directory. Uploading test results to DTP allows you to associate coverage data with individual tests and view the information on DTP.
The static and dynamic coverage data must be merged into one coverage.xml file. To merge the coverage data and send the merged information to DTP, run dotTEST or Jtest with the following arguments:
-staticcoverage
- Provides the path to the static_coverage.xml generated by dotTEST or Jtest-runtimeCoverage
- Provides the path to the runtime_coverage_[timestamp].data downloaded via CAM or generated by SOAtest. You can provide a path to a folder that contains many .data files from multiple testing sessions.-publish
- sends the merged coverage data to DTP-config
"builtin://Calculate Application Coverage"
- specifies the built-in test configuration required to merge the coverage dataYour command line may resemble the following:
dottestcli.exe -runtimeCoverage [path] -staticCoverage [path] -publish |
jtestcli -staticcoverage [path] -runtimecoverage [path/dir] -config "builtin://Calculate Application Coverage" -publish |
The
-publish
option is required to send the merged coverage data to DTP. Alternatively, you can configure the report.dtp.publish=
true
option in the .properties file where you configure dotTEST or Jtest.
You can collect coverage information for multiple users that are simultaneously accessing the same Java or IIS web application server. This allows QA engineers to perform parallel testing sessions and associate coverage with individual users.
Collecting coverage data from multiple users requires additional configuration steps before you start your testing session. You need to:
You can enable the multi-user mode by modifying the invocation of the dotTEST IIS Manager tool (see Step 2: Attach the Coverage Agent to the Application Under Test (AUT)). Launch the tool with the -multiuser
switch:
dottest_iismanager.exe -multiuser |
You can enable the multiple-user mode by modifying the options in the the agent.properties file, which is included in the monitor.zip package (see Generating Static Coverage with Jtest). Open the file and configure the following option:
jtest.agent.enableMultiuserCoverage=true |
Modify the the HTTP request header of your browser by configuring the Test-Operator-ID option with a unique User ID.
A convenient way to add a Test-Operator-ID is to install one of the browser plugins that allow you to easily modify HTTP headers. The following example shows a Test-Operator-ID specified in Chrome with the ModHeader plugin.
Provide your User ID when connecting CAM to the Coverage Agent (see Step 3: Connect CAM or SOAtest to the Coverage Agent). The User ID must be identical to the Test-Operator-ID provided to your browser.
Perform testing sessions, download the results, and mergee the coverage data, as described in steps 4-7 above. When downloading the results from CAM, ensure that the Session Tag field is completed with a tag unique to each user. We recommend that the session tag include the User ID.