C/C++test CT is designed for close integration with build systems.
Three steps are performed during the project build:
- Source code is instrumented with the
cpptestcc
utility. - Instrumented source code is compiled into an object file.
- All instrumented and non-instrumented object files are linked with the code coverage tool library, as well as any additional libraries required to form the final testable binary artifact.
Build system integration involves prefixing compiler commands with the cpptestcc
code instrumentation tool and adding the coverage runtime library during the linking phase. The build process can optionally be extended with additional targets for report generation.
For popular build systems such as CMake or Bazel, dedicated packages simplify the integration process. For more information, see Collecting Coverage for CMake Projects and Collecting Coverage for Bazel Projects.
For build systems without dedicated integration packages, custom integration is required. That involves modifying compilation and linking rules in appropriate build scripts. The goal is to prefix compilation command lines with the cpptestcc
utility and extend the linker command line to include the code coverage tool runtime library.
The sections Integrating the cpptestcc Code Instrumentation Utility and Linking Instrumented Code explain steps required for custom integrations.