Function Coverage
Percentage of unique functions that current test cases execute at least once
Since R2023b
Description
This metric indicates how many unique functions in your code the current test cases execute at least once. For instance, if the function coverage of your code is 50%, then the test cases do not execute half of the functions in your code. To increase function coverage, add test cases that can execute the untested functions.
Polyspace Implementation
To calculate the function coverage, Polyspace® counts the number of functions that execute during a test case
(func_x) and the number of functions that are in the scope of
the test cases
(func_tot):
Function Coverage = 100*func_x/func_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() with (x== -1,y==1), then the
functions func1() and foo() execute, resulting
in func_x = 2 and a function coverage of (2/3) or
67%.Examples
Version History
Introduced in R2023b