You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function testFunction($a) { // This is a very common syntaxes for singleton definition.
if (!$a) {
$a = 'empty';
}
return $a;
}
Then, If i do an assert:
$this->assertEquals('empty', testFunction(null));
Everything will be great.
Code coverage will be 100%. But it is not true. Code coverage should track that "else" statement was never executed and highlight this moment.
So, code coverage should track if-elseif-else blocks, and if it founds if-elseif without else and none of the tests executed if-elseif blocks in such matter that they did not stepped inside into this block, it should mark last line of if-elseif as an uncovered and account it into statistics.
I hope I managed to explain it clearly :)
The text was updated successfully, but these errors were encountered:
There is no "else" statement in your code. And in fact the coverage of 100% is true, because based on the data available to PHPUnit, every line was executed once.
What you want is branch coverage, and it is on the list of things that should be implemented, but not in the way you suggest here. It should be an independent metric, i.e. covered lines are still covered, but branches should get additional information about their decision coverage.
I have a function.
Then, If i do an assert:
Everything will be great.
Code coverage will be 100%. But it is not true. Code coverage should track that "else" statement was never executed and highlight this moment.
So, code coverage should track if-elseif-else blocks, and if it founds if-elseif without else and none of the tests executed if-elseif blocks in such matter that they did not stepped inside into this block, it should mark last line of if-elseif as an uncovered and account it into statistics.
I hope I managed to explain it clearly :)
The text was updated successfully, but these errors were encountered: