Code coverage overview

Source code coverage consists of identifying which portions of a program are executed or not during a given test case. Source code coverage is recognized as one of the most effective ways of assessing the efficiency of the test cases applied to a software application.
The code coverage tool can provide the coverage information for the following source code elements:
  • Statement blocks, decisions, and loops.
  • Function or procedure calls.
  • Basic conditions, modified conditions/decisions (MC/DC), multiple condition, and forced condition.
  • Procedure entries and exits.
  • Terminal or potentially terminal statements
  • Statements that are considered non-coverable in C.
See Coverage levels for more details about each coverage level.

Information modes

The information mode is the method used to code the trace output. This has a direct impact of the size of the trace file as well as on CPU overhead. You can change the information mode in the coverage type settings. See Changing code coverage settings.

There are three information modes:
  • Default mode: Each branch generates one byte of memory. This offers the best compromise between code size and speed overhead.
  • Compact mode: This is functionally equivalent to Pass mode, except that each branch needs only one bit of storage instead of one byte. This implies a smaller requirement for data storage in memory, but produces a noticeable increase in code size (shift/bits masks) and execution time.
  • Hit Count mode: In this mode, instead of storing a Boolean value indicating coverage of the branch, a specific count is maintained of the number of times each branch is executed. This information is displayed in the code coverage report.

Count totals are given for each branch, for all trace files transferred to the report generator as parameters. In the code coverage report, branches that have never been executed are highlighted with an asterisk '*'. The maximum count in the report generator depends on the amount of memory available on the computer running the tests. If this maximum count is reached, the report signals it with a Maximum reached message.

Note: The last bracket (}) in a function after a return statement is always displayed in red in the coverage report, even if the function reports 100% coverage.

On-the-fly display

By default, code coverage generates a report when the execution ends. The on-the-fly mode generates code coverage results dynamically during the execution. This is useful for applications that never exit or to interact with the execution during the analysis, for example if you want to stop the code coverage when you reach a specified coverage rate threshold.
Feedback