Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Indicates how many functions in the source code were reached at least once during execution. Complete, 100% function coverage is obtained if all functions are reached at least once.

 


Call Coverage

Indicates how many defined function or method calls were executed at program runtime. Complete, 100% call coverage is obtained if all functions or methods calls were executed. 

...

Code Block
class A
{
public:
    A() {}
    A(const A&) {}
    A(int val) {}
    A& foo() 
    {
        return *this;
    }
    ~A() {}
};


void funcA(const A& a) {}
A& operator+(const A & a, const A & b) {}


void defaultConstructorCall()
{
    A objA;                // Default constructor call - not included
    A objArr[10];          // Default constructor calls - not included
    A objB = objA;         // Copy constructor call       - not included
    A objC = 10;           // Implicit call of A(int) constructor - not included

    funcA(10);             // Implicit call of A(int) constructor - not included

    A res = objA + objA;   // Operator + call - not included 
						   // Copy constructor call - not included

    A* objD = new A();    // Default constructor call - not included
						  // Operator new call - not included

    delete objD;          // Destructor call - not included
						  // Operator new call - not included

    A* objE = new A[10];  // Default constructor calls  - not included
                          // Operator new call - not included

    delete[] objE;        // Destructor calls - not included
                          // Implicit destructor calls - not included
}

 

 



Line Coverage

Indicates how many executable lines of source code were reached by the control flow at least once. Complete, 100% line coverage is obtained if all executable lines are reached at least once.

 


Statement Coverage

Indicates how many executable source code statements were reached by the control flow at least once. Complete, 100% statement coverage is obtained if all executable statements are reached at least once.

 


Block Coverage

Similar to Line Coverage—except that with Block Coverage, the unit of measured code is a basic block (see the definition of this term in the previous table). This indicates how many basic blocks in the source code were reached by the control flow at least once. 


Path Coverage

Indicates if each possible path in a given function was followed by the control flow. Branching points used to single out paths (see an explanation of this term in the previous table) are the same as in Decision (Branch) Coverage.

...

To prompt C++test to show only uncovered paths, disable the Highlight covered elements button in the Coverage view toolbar. To prompt C++test to show only covered paths, disable the Highlight not covered elements. Note that the Highlight next/prev element buttons iterate through unexpected paths only when the Highlight not covered elements button is disabled. 


 


Decision (Branch) Coverage

...

If there are no decisions in a file, C++test reports that this metric is not available (using an "N/A" label). 


Modified Condition/Decision Coverage (MC/DC)

MC/DC conforms to the international technical standard DO-178B/C (RTCA), which specifies the software certification criteria for mission-critical equipment and systems within the aviation industry. This includes real time embedded systems.

According to the DO-178B/C standard, the following three conditions must be satisfied to obtain complete (100%) MC/DC coverage:

...

Note that in order to make a single condition covered, at least two test cases need to be executed: one with the condition evaluated to true and a second with this condition evaluated to false. 


MC/DC Example

For example, consider the following code:

...

C++test will report the MC/DC coverage for such an example to be 67% [2/3 conditions covered]. You can see the actual values that the conditions and decision evaluated to in a tool tip by placing your cursor above on the condition.


 

Simple Condition Coverage

...

To see the actual boolean value that the condition evaluated to, place your cursor above it. The value will be shown in a tool tip. 


Increasing Coverage

Strategies for improving coverage are discussed in Improving Test Coverage.