Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space ENGINES1031 and version 10.3.3

In this section:

Table of Contents
maxLevel1

Requirements

  • Visual Studio 2010, 2012, 2013 or 2015
  • 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: 

  1. Add the CPPTEST_HOME environment variable pointing to [INSTALL_DIR] directory.
  2. Add the [INSTALL_DIR]/bin directory to your PATH variable to ensure access to the cpptest.dll library.
  3. Go to the [INSTALL_DIR]/integration/msbuild directory.
  4. Copy the parasoft-coverage.xml and parasoft-coverage.props files to the directory that contains your Visual Studio solution.
  5. (Optional) Add the parasoft-coverage.xml and parasoft-coverage.props files in the solution directory to source control.
  6. Open your solution with Visual Studio.
  7. Go to View> Other Windows> Property Manager.
  8. Select the solution projects or specific build configurations of the projects for which you want to generate a coverage report.
    Image Added

    You might want to create dedicated build configurations that will be used only for the purpose of collecting coverage. 
       
  9. 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.
    Image Added

    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: 

  1. Double-click the project, configuration or the parasoft-coverage.props file to open its Property Pages.
  2. 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.
    Image Added
  3. Go to Configuration Properties> Parasoft DTP for C/C++ to select the settings from the drop-down menus.

General Settings

NameValueDescription
DTP Engine Location [path] Specifies your DTP Engine for C/C++ 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

NameValueDescription
Line Coverage 

Yes

No

Allows you to enable or disable collecting coverage during a build. This option is enabled by default. 

Advanced Settings


NameValueDescription
Enable Coverage Optimization 

Yes

No

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 

Yes

No

Allows you to enable or disable optimized coverage corruption detection. Requires the Coverage Optimization option to be set to Yes.

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 

Yes

No

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 

Yes

No

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.

Info
titleImportant

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:

  1. Ensure the Line Coverage option in Configuration Properties> Parasoft DTP for C/C++ > Coverage Settings is enabled.
  2. Choose the configuration and platform you want to use for the run from the drop-down menus on the Visual Studio toolbar.
    Image Added

  3. Run a clean build of your project.
  4. 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.
  5. The .clog file that contains coverage information will be generated in your current working directory. The default name of the file is cpptest_results.clog.
  6. Ensure the Line Coverage option in Configuration Properties> Parasoft DTP for C/C++ > Coverage Settings is enabled.
  7. Choose the configuration and platform you want to use for the run from the drop-down menus on the Visual Studio toolbar.
    Image Added

  8. Run a clean build of your project.
  9. 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.
  10. The .clog file that contains coverage information will be generated in your current working directory. The default name of the file is cpptest_results.clog.

Reporting

You can generate coverage reports from the command line or with the Visual Studio DTP Plugin for C/C++

Command Line

  1. Go to your solution directory.

  2. Run cpptestcli.exe with the Coverage built-in configuration and the .clog file as an input. Your command may resemble the following:

    Code Block
    cpptestcli.exe -config "builtin://Coverage" -input ATM/Debug/cpptest_results.clog 
  3. Review the XML and HTML coverage reports which are generated in the reports subdirectory of your solution directory. 

    Info
    titleImportant

    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++ 

  1. Go to Parasoft>Options>Engines.
  2. Ensure that DTP Engine for C/C++ is enabled.
  3. 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.
    Image Added

    Info
    titleImportant

    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.

  4. Run the Coverage built-in configuration on your selected projects.

  5. 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.
    Image Added
  6. View the generated report in the Visual Studio main window.

Removing the Parasoft Integration

To uninstall the parasoft-coverage property sheet:

  1. Go to View>Other Windows>Property Manager.
  2. Browse the projects and configurations for the parasoft-coverage.props files you want to remove. The files must be removed manually from individual configurations.
    Image Added
  3. Right-click the selected files and choose Remove from the menu.

  4. The parasoft-coverage.props files will be removed only from the project configurations you selected.

...