When checking statement coverage for my code:
double programme(double x, double y)
{
double z
if(x>=5){
z = 15;
}
else if(x>=3){
z= 10;
}
else {
z=0;
}
if (y>z)
{
z=y;
}
return z;
}
using two test cases (eg test 1: x = 6, y = 10 and test 2: = 3, y =5)
I'm not sure if the statement coverage is equal to 100% or 66% based on the fact that I'm not sure if you count the last if statement as it is false both times.
There are eight statements in your method - three conditionals, four assignments, and a return
:
if (x>=5)
z=15
if (x>=3)
z=10
z=0
if (y>z)
z=y
The first test case covers statements 1, 2, 6, and 8. The second test case covers 1, 3, 4, 6, and 8. Therefore, statements 1, 2, 3, 4, 6, and 8 are covered, for 6 out of 8 or 75% coverage.