Using cpptestcli to create coverage report
Setup
I've copied the cpptest-coverage.cmake to my project and included it into my CMake project.
Inside the cpptest-coverage.cmake I modified the following line:set(CPPTEST_COVERAGE_WORKSPACE ${CPPTEST_BINARY_DIR}/cpptest-coverage/${CMAKE_PROJECT_NAME})
to have all temporary files in my build folder.
I see in the make build that the CMAKE_CXX_COMPILER_LAUNCHER uses cpptestcc and that my unit tests link against libcpptest_static.a
Furthermore I see that my .psrc is taken into account where I defined the workspace to the same build target directory as defined in CPPTEST_COVERAGE_WORKSPACE:
cpptestcc.workspace=/workspaces/project/build/cpptest-coverage/project_app
The result after running my unit tests is the file:
/workspaces/project/build/cpptest-coverage/project_app/project_app.clog
Problem
Now i want to create a coverage report with cpptestcli.
/opt/e3sdk/parasoft-cli/cpptest/cpptestcli -showdetails -publish -localsettings /workspaces/project/scripts/parasoft/cpptest-config/cpptest.settings -data /workspaces/project/build/cpptest-coverage/project_app -import /workspaces/project/build/cpptest-coverage/project_app -report /workspaces/project/build/cpptest-report -config "builtin://Load Application Coverage" -appconsole stdout
The result is:
Parasoft C/C++test Professional 2023.1.1 (10.6.2.20230621B2144) -- Copyright (C) 2023 Parasoft Corporation [0%] Importing 1 project(s)... [0%] Creating project project_app... [0%] Create. [30%] ...failed, problem occurred: "Invalid project description. /workspaces/project/build/cpptest-coverage/project_app overlaps the workspace location: /workspaces/project/build/cpptest-coverage/project_app" [100%] ...1 out of 1 projects successfully imported. [100%] Done
Question
It looks like I'm doing something wrong with the -import and -data parameter.
What is the right combination so that cpptestcli creates a coverage report based on the project_app.clog ?
Comments
-
Hi Senji,
when working with the CMake extension for code coverage analysis I would suggest using C/C++test Standard instead of C/C++test Professional. The latter is more suitable to work with its unit testing framework and it is a bit more more complex for setup of new projects on CLI.
Here you will find an example of collecting code coverage from CMake based projects using C/C++test Standard: https://docs.parasoft.com/display/CPPTEST20241/Collecting+Application+Coverage+for+CMake+Projects
If you need a flexible solution for CMake and VS Code integration, which provides extensive reporting for multiple coverage metrics (including MC/DC), you may look at the new Parasoft solution C/C++test CT. For more details, you will need to contact your sales representative.0