Issue
Requirements:
- Netbeans with PHPUnit(6.9)
- EDIT: Same applies, for example, to PHPStorm
How to:
- Exclude lines from code coverage.
- Exclude code blocks (lines) from code coverage.
Solution
If you are trying to achieve 100% code coverage but have one or more lines that you cannot test, you can surround them with special annotations. They will be ignored in the code coverage report.
if (($result = file_get_contents($url)) === false) {
// @codeCoverageIgnoreStart
$this->handleError($url);
// @codeCoverageIgnoreEnd
}
Edit: I have found that Xdebug often considers the closing brace to be executable. :( If that happens, move the end tag below it.
Answered By - David Harkness
Answer Checked By - David Marino (JavaFixing Volunteer)