Function Call Coverage
Percentage of function calls that current test cases execute at least once
Since R2023b
Description
This metric indicates how many of the function calls in your code are executed by the current test cases. For instance, if the function call coverage of your code is 50%, then the current tests do not execute half the function calls in your code. To increase function call coverage, add test cases that execute the untested function calls.
Polyspace Implementation
To calculate the function call coverage, Polyspace® counts the number of function calls that the test cases execute
(call_x) and the number of function calls that are in the
scope of the test cases
(call_tot):
Function Call Coverage = 100*call_x/call_tot
int func1(){return 1;}
int func2(){return 2;}
int foo(int x, int y)
{
if (x < 0 && y>0)
return func1();
else if (x > 0 && y==0)
return func2();
else
return func1();
}foo(), there are three function calls. For a test
case, Polyspace counts how many of the calls execute. If you test
foo() with (x== -1,y==1), then only the
call to func1() executes, resulting in call_x =
1 and a function call coverage of 33%.Polyspace Test™ does not consider calls to class constructors as function calls. The function call coverage metrics exclude calls to class constructors.
Examples
Version History
Introduced in R2023b