Instrumentation of Included Files

Header files and other included files can be instrumented with Testwell CTC++ like any other source file. Based on the include mechanism of C and C++, the handling and reporting consequences differ slightly.

For the purpose of coverage measurement, "header" and "included file" can be seen as synonyms. Both terms are used here, depending on the context. Relevant for Testwell CTC++ is that these files are not directly compiled, but included via #include in another source file. Not relevant is if these files are actually header files, or if they are, for example, normal source files included for unit testing.

To instrument included files, the setting for the configuration parameters EXCLUDE, NO_EXCLUDE and NO_INCLUDE must be checked and adapted if necessary: By default, all included files are excluded from instrumentation with the setting
EXCLUDE = %INCLUDES%
to avoid instrumentation of system headers. The included file and all files including it must be instrumented.

During instrumentation and testing, each inclusion of an included file inside a source file is treated as an own entity: The included file is represented in the symbol file(s) in an independent "copy" for each inclusion. The copies might differ due to preprocessor directives. Each copy of the included file has its own, independent counters.

When reports are generated from symbol and data files with ctcreport, the different copies of an included file are consolidated to one or more variants.

The including files can be excluded from reports, but they have to be instrumented.

Note: For files included inside functions, the included code is completely treated as a part of the function.