{"action":"created","issue":{"url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/1720","labels_url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/1720/labels{/name}","comments_url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/1720/comments","events_url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/1720/events","html_url":"https://github.com/sebastianbergmann/phpunit/issues/1720","id":79478665,"number":1720,"title":"Uncoverable Code","user":{"login":"DasRed","id":2239808,"avatar_url":"https://avatars.githubusercontent.com/u/2239808?v=3","gravatar_id":"","url":"https://api.github.com/users/DasRed","html_url":"https://github.com/DasRed","followers_url":"https://api.github.com/users/DasRed/followers","following_url":"https://api.github.com/users/DasRed/following{/other_user}","gists_url":"https://api.github.com/users/DasRed/gists{/gist_id}","starred_url":"https://api.github.com/users/DasRed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DasRed/subscriptions","organizations_url":"https://api.github.com/users/DasRed/orgs","repos_url":"https://api.github.com/users/DasRed/repos","events_url":"https://api.github.com/users/DasRed/events{/privacy}","received_events_url":"https://api.github.com/users/DasRed/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-22T14:37:18Z","updated_at":"2015-06-19T06:33:09Z","closed_at":"2015-06-19T04:20:58Z","body":"i have tested a class method witch contains try catch finally. Every part in the method is tested but the code coverage shows not 100%.\r\nI reduced it to an example.\r\n\r\n**The Class to test**\r\n```php\r\nclass A\r\n{\r\n\tpublic function abc($in)\r\n\t{\r\n\t\ttry\r\n\t\t{\r\n\t\t\tif ($in === 1) { $a = 2;}\r\n\t\t\telse { throw new \\Exception('A'); }\r\n\t\t}\r\n\t\tcatch (\\Exception $e)\r\n\t\t{\r\n\t\t\t// do stuff\r\n\t\t\t$a = 3;\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\tfinally\r\n\t\t{\r\n\t\t\t$a = 1;\r\n\t\t}\r\n\r\n\t\treturn true;\r\n\t}\r\n}\r\n```\r\n\r\n**The Test Case**\r\n```php\r\nrequire_once __DIR__ . '/a.php';\r\n/**\r\n * @coversDefaultClass A\r\n */\r\nclass ATest extends \\PHPUnit_Framework_TestCase\r\n{\r\n\t/**\r\n\t * @covers ::abc\r\n\t */\r\n\tpublic function testAbc()\r\n\t{\r\n\t\t$a = new A();\r\n\r\n\t\t$this->assertTrue($a->abc(1));\r\n\t\t$this->assertFalse($a->abc(2));\r\n\t}\r\n}\r\n```\r\n\r\n**The Test Configuration**\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<phpunit>\r\n    <testsuites>\r\n        <testsuite name=\"A\">\r\n            <directory suffix=\"Test.php\">./*</directory>\r\n        </testsuite>\r\n    </testsuites>\r\n</phpunit>\r\n```\r\n\r\n**The Code Coverage Result**\r\n![image](https://cloud.githubusercontent.com/assets/2239808/7772762/7ba90df0-00a0-11e5-90d6-e8f5be491c90.png)\r\nThe last line of method A::abc ( the closing } of function) is always uncovered\r\n\r\n**Workaround**\r\nIf i remove the finally block and put the statement of the finally block into the try and catch block, the coverage switches to 100%.\r\nBut this is not really a workaround.\r\n\r\n**Environment**\r\nWindows 7\r\nPHP 5.6.7\r\nPHPUnit 4.6.4 und PHPUnit 4.6.6\r\n"},"comment":{"url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/comments/113393337","html_url":"https://github.com/sebastianbergmann/phpunit/issues/1720#issuecomment-113393337","issue_url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/1720","id":113393337,"user":{"login":"DasRed","id":2239808,"avatar_url":"https://avatars.githubusercontent.com/u/2239808?v=3","gravatar_id":"","url":"https://api.github.com/users/DasRed","html_url":"https://github.com/DasRed","followers_url":"https://api.github.com/users/DasRed/followers","following_url":"https://api.github.com/users/DasRed/following{/other_user}","gists_url":"https://api.github.com/users/DasRed/gists{/gist_id}","starred_url":"https://api.github.com/users/DasRed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DasRed/subscriptions","organizations_url":"https://api.github.com/users/DasRed/orgs","repos_url":"https://api.github.com/users/DasRed/repos","events_url":"https://api.github.com/users/DasRed/events{/privacy}","received_events_url":"https://api.github.com/users/DasRed/received_events","type":"User","site_admin":false},"created_at":"2015-06-19T06:33:09Z","updated_at":"2015-06-19T06:33:09Z","body":"@sebastianbergmann okay i can put it into the php-code-coverage project. But this is not an edge case. This happends by using the finally and i think many people use the finally and a return in the exception block. So what is the reason, that this should be an edge case?"}}