As a general rule, to tell me when a brace should be considered “covered” or “not covered”?
There is a "Edge Cases" section in the phpunit documentation , but this seems to be not complete, as I found out in the last browse days :)
What I personally have never seen is your second example of failure. I also could not reproduce it: I could not find a combination of PHP / xDebug / PHPUnit where this did not work. (Play below)
The same can be said of another case that you showed. For everyone, I could test both closing curly braces that were detected as “not feasible / reachable,” as you would expect.
So, for both of these cases, // @codeCoverageIgnore or // @ codeCoverageIgnore is not required [Home | The end].
As @Derick explained in the comments for further analysis, you will need the whole file.
Play
<?php class Foo { public $myProperty; public function myMethod() { $this->myProperty = '1'; } } <?php require __DIR__ . '/closingBrace.php'; class FooTest extends PHPUnit_Framework_TestCase { public function testMyMethod() { $x = new Foo(); $x->myMethod(); } }
Running phpunit --coverage-text fooTest.php
Code Coverage Report 2012-01-12 10:17:32 Summary: Classes: 100.00% (1/1) Methods: 100.00% (1/1) Lines: 100.00% (2/2)
which only marks $this->myProperty = '1'; closing bracket as executable file.
source share