Slide 33
Slide 33 text
How to trick Code Coverage
“Ohh, I‘m a liar. Yeah.“ – Henry Rollins
When you run a Test Case
it will always cover some code
For example, calling assertNotNull(new MyClass())
for each class should yield 5-20% coverage
without any real value (@covers might help…)
However, you can also fake tests, e.g. no/fake
asserts, redundant checks, (some) mocks, …
-> So, we shouldn‘t write tests anymore?
… and you can fake code as well, e.g. if you require
“no if/else, switch/case etc” and developers get
creative
-> So, we shouldn‘t write code anymore?
while ($status === "done") {
echo "Status: Done";
break;
}