In this section:
Requirements
- Visual Studio 2010, 2012, 2013, 2015 or 2017
- DTP Engines for C/C++ 32-bit distribution
- Visual Studio DTP Plugin for C/C++
Installation
The following instructions assume that [INSTALL_DIR] refers to the DTP Engines for C/C++ installation directory. The default name of this directory is cpptest.
To integrate the Parasoft coverage functionality with MS Build:
- Add the CPPTEST_HOME environment variable pointing to [INSTALL_DIR] directory.
- Add the [INSTALL_DIR]/bin directory to your PATH variable to ensure access to the cpptest.dll library.
- Go to the [INSTALL_DIR]/integration/msbuild directory.
- Copy the parasoft-coverage.xml and parasoft-coverage.props files to the directory that contains your Visual Studio solution.
- (Optional) Add the parasoft-coverage.xml and parasoft-coverage.props files in the solution directory to source control.
- Open your solution with Visual Studio.
- Go to View> Other Windows> Property Manager.
- Select the solution projects or specific build configurations of the projects for which you want to generate a coverage report.
You might want to create dedicated build configurations that will be used only for the purpose of collecting coverage.
- 9. Right-click the selected projects or configurations, choose Add Existing Property Sheet… from the menu and point to the parasoft-coverage.props file in your solution directory.
If you select a project, the file will be added to all test configurations in the project. In the above example, the file will be added to all four configurations in the ATM project, and only two selected configurations in the BugDetective project.
Configuration
You can configure code instrumentation with Property Pages on the level of your project, configuration or parasoft-coverage.props file.
To configure code instrumentation:
- Double-click the project, configuration or the parasoft-coverage.props file to open its Property Pages.
- If you modify the Property Pages from the project level, select the test configuration and the platform from the drop-down menu. Your settings will apply only to the selected configuration.
Go to Configuration Properties> Parasoft DTP for C/C++ to select the settings from the drop-down menus.
General Settings
Name | Value | Description |
---|---|---|
DTP Engine Location | [path] | Specifies your DTP Engine for C/C++test DTP Engine location. The default is the value set for your CPPTEST_HOME environment variable. |
Compiler Configuration | [complier configuration] | Specifies the configuration of your compiler. The default is AutoDetect . |
Workspace Location | [path] | Specifies the directory that contains data used to generate the coverage report. The default is your solution directory location. |
Coverage Settings
Name | Value | Description |
---|---|---|
Line Coverage |
| Allows you to enable or disable collecting coverage during a build. This option is enabled by default. |
Advanced Settings
Name | Value | Description |
---|---|---|
Enable Coverage Optimization |
| Allows you to enable or disable coverage optimization. If enabled, execution time overhead will be reduced. This option is enabled by default. |
Enable Optimized Coverage Corruption Detection |
| Allows you to enable or disable optimized coverage corruption detection. Requires the Coverage Optimization option to be set to If enabled, it allows detection of corrupted coverage memory buffers, which are used when the Coverage Optimization is enabled. This option is disabled by default. |
Enable Coverage Early Initialization |
| Allows you to enable or disable coverage early initialization. If enabled, the process of collecting coverage will start automatically. If disabled, the process must be initiated manually. This option is enabled by default. Contact Parasoft Support for more information about manual initialization of collecting coverage. |
Enable Coverage Auto-Finalization |
| Allows you to enable or disable automatic coverage finalization. If enabled, the process of collecting coverage information will be finalized automatically. If disabled, the process must be finalized manually. This option is enabled by default. Contact Parasoft Support for more information about manual finalization of collecting coverage. |
Important
If the settings selected on the project or configuration level differ from the settings specified on the parasoft-coverage.props level, the project or configuration level settings will have priority and will be used during the build. The settings selected on a given level are in bold, whereas the settings inherited from the higher level are in a regular font.
Build and Execution
To build your code-instrumented application and collect coverage information during a run of the executable:
- Ensure the Line Coverage option in Configuration Properties> Parasoft DTP for C/C++ > Coverage Settings is enabled.
- Choose the configuration and platform you want to use for the run from the drop-down menus on the Visual Studio toolbar.
- Run a clean build of your project.
- Run the executable that was built. You can run the executable from the command line, with the Visual Studio Debugger or in any other way required for your project.
- The
.clog
file that contains coverage information will be generated in your current working directory. The default name of the file iscpptest_results.clog
. - Ensure the Line Coverage option in Configuration Properties> Parasoft DTP for C/C++ > Coverage Settings is enabled.
- Choose the configuration and platform you want to use for the run from the drop-down menus on the Visual Studio toolbar.
- Run a clean build of your project.
- Run the executable that was built. You can run the executable from the command line, with the Visual Studio Debugger or in any other way required for your project.
- The
.clog
file that contains coverage information will be generated in your current working directory. The default name of the file iscpptest_results.clog
.
Reporting
You can generate coverage reports from the command line or with the Visual Studio DTP Plugin for C/C++
Command Line
Go to your solution directory.
Run
cpptestcli.exe
with the Coverage built-in configuration and the.clog
file as an input. Your command may resemble the following:cpptestcli.exe -config "builtin://Coverage" -input ATM/Debug/cpptest_results.clog
Review the XML and HTML coverage reports which are generated in the reports subdirectory of your solution directory.
Important
If your configured workspace location is different than the default solution directory, use the -workspace switch with the path to the directory that is specified as workspace location.
Visual Studio DTP Plugin for C/C++
- Go to Parasoft>Options>Engines.
- Ensure that DTP Engine for C/C++ is enabled.
Enter a new set of parameters in the Arguments field to reconfigure the run:
-${configuration}
: Uses the test configuration specified in the Parasoft>Configuration settings. Ensure that the active test configuration is set to Coverage.
--input <path/to/file.clog>
: Specifies the path to the.clog
file that contains coverage information.
- (optional)${scope}
: Uses the current UI selection to set the scope and allows you to report coverage for individuals projects or files selected in Solution Explorer.Important
Ensure that your coverage Workspace is the same location as the plugin Working directory. In case the locations are different, provide the
–workspace <path/to/workspace>
parameter in the Arguments field.Run the Coverage built-in configuration on your selected projects.
- Select the Generate reports check box in the pop-up window when the run is completed. You can use the Configure… link to specify report configuration settings.
- View the generated report in the Visual Studio main window.
Removing the Parasoft Integration
To uninstall the parasoft-coverage property sheet:
- Go to View>Other Windows>Property Manager.
- Browse the projects and configurations for the parasoft-coverage.props files you want to remove. The files must be removed manually from individual configurations.
Right-click the selected files and choose Remove from the menu.
The parasoft-coverage.props files will be removed only from the project configurations you selected.