Function Exit Coverage
Description
A function exit point is any statement that pushes the
control flow out of the function. For instance, a return
statement is an exit point.
This metric indicates how many of the function exit points in your code you reach during testing. For instance, if the function exit coverage of your code is 50%, then the current test cases do not reach half of the function exit points in your code. To increase function exit coverage, add test cases that can reach the untested exit points.
Note that in the Polyspace Platform user interface, you do not see function exit coverage in a separate column on the Results List pane. If you select a function name on this pane, the Result Details pane shows both function coverage and function exit coverage.
Polyspace Implementation
To calculate the function exit coverage, Polyspace® counts the number of function exit points (FX_x)
the test cases reach during execution and the total number of function exit points
(FX_tot):
Function Exit Coverage = 100*FX_x/FX_tot
int foo(int x)
{
int y = (x >= 5 && x != 7);
if (x < 0)
return 1; //Exit point 1
else if (x > 0 && y)
return 2;//Exit point 2
else
return -1;//Exit point 3
}foo() with x== -1, then the test case
reaches first exit point after the if(x<0) statement,
resulting in FX_x = 1 and a function exit coverage of 33%.Examples
Version History
Introduced in R2023b