C/C++test ships with a script that allows you to quickly reconfigure your MSBuild project to integrate coverage analysis. This script supports both Visual Studio and CMake-generated MSBuild projects. The script creates a backup of the target .vcxproj file and then modifies it to enable the requested Parasoft features on all build targets.

C/C++test includes a Python script launcher to run the included tools, which can be found at:

<CPPTEST_INSTALL_DIR>/bin/engine/bin/cpptestpy.exe

The MSBuild integration script is in the following location:

<CPPTEST_INSTALL_DIR>/integration/msbuild/msbuild_cpptest.py

To collect coverage for an MSBuild project:

  1. Setup the environmental variables.

Be sure to not use double quotes after = which will cause incorrect string interpretation. 

    1. Setup the CPPTEST_INSTALL_DIR variable.

      set CPPTEST_HOME=<CPPTEST_INSTALL_DIR>
    2. Setup the PATH variable.

      set PATH=%PATH%;%CPPTEST_HOME%\bin\engine\bin
  1. (CMake only) Generate your MSBuild files using CMake. 

    cd <PROJECT_DIR>
    mkdir build
    cd build
    cmake ..
  2. Run the integration script. 

    <cpptestpy.exe> <msbuild_cpptest.py> -c -f project.vcxproj
  3. Build the project using MSBuild.

    msbuild -t:Rebuild project.sln
  4.  To collect coverage, go to the build directory and run the project.

    cd x64\Debug
    project.exe

    A .clog file that contains coverage information will be generated in your current working directory. 
    The default name of the file is cpptest_results.clog.

  5. Generate the coverage report.

    cpptestcli.exe \
    -config "builtin://Coverage" \
    -input cpptest_results.clog

    For more information about generating reports from the .clog file, see Generating a Coverage Report from the Command Line.

  • No labels