In this section
Cobertura is a free, open source Java tool that calculates the percentage of code accessed by unit tests. Cobertura runs produce HTML or XML files indicating what lines of code and branches were tested.
The Parasoft Cobertura Extension transfers Cobertura Java code coverage results to Parasoft (DTP) so that the coverage can be processed and viewed along with other data points. The extension can process output that comes directly from Cobertura, as well as Cobertura-formatted outputs produced by other tools, such as the Istantbul coverage tool.
Cobertura provides coverage information for your unit test cases, but it doesn’t report which test cases achieved what coverage. If test case coverage association is important for your team, contact Parasoft to ask about the coverage capabilities provided by the Parasoft Jtest.
mvn cobertura:cobertura
parasofttestcli.sh -Dsettings="C:\sample\cobertura-settings.properties" Ddata.dir="C:\sample\sampleProjectFolder" -Dresults.file=c:\sample\sampleProjectFolder\target\site\cobertura\coverage.xml |
The following settings are required.
-Dresults
This parameter specifies the path to the Cobertura-formatted coverage XML results file. This file is typically located in <project_home>/target/site/cobertura directory. The path should be relative to the -Ddata.dir value. Example configuration:
–Ddata.dir=<project_home>
–Dresults.file=target/site/Cobertura.coverage.xml
You can combine coverage from multiple module projects into a single report by using wildcards to specify the various coverage.xml files. The following example shows how to reference coverage files in sub-projects if the -Ddata.dir
setting points to a top-level project:
–Dresults.file=**/coverage.xml
Multiple result files can also be specified by using result file options that match the regular expression results[0-9]*\.file
. For example, all of these options could be used:
-Dresults.file=… -Dresults1.file=… -Dresults314.file=… |
Path to the settings configuration file (see Configuration).
-Ddata.dir
Specifies the path to the source code of the project that was tested. This is used to collect source control metadata (e.g., authorship, last updated, etc.) for DTP reporting and processing.
The following parameter is optional.
-Dparasoft.local.storage.dir
Specifies where log files are generated. The recommended location is ${project.base.dir}/.parasoftanalyzer
.
For example:
-Dparasoft.local.storage.dir=.parasoftanalyzer
See the Parasoft Analyzer package documentation for a complete list of configurations.
The following settings are required to run the Cobertura extension.
Enables the analyzer. Values are true
or false
.
Example:
analyzer.cobertura.enabled=true
The following updates have been made to the Cobertura extension.
The Parasoft End User License Agreement (EULA) is available at https://www.parasoft.com/parasoftlicense.