Code coverage with PHPUnit


When running PHPUnit tests with code coverage, I get <100% coverage but when I open the file, no lines are marked as uncoverd.
When I comment some tests to get lower coverage, uncovered lines are indeed marked in red.

Is there a way to jump to first uncovered line or get a list of them?

Jakub Szymanowski

Comment actions Permalink

Well ... sometimes you get not 100% coverage (but you see no uncovered lines) because you do not have return statements in some functions so such "uncovered" lines would typically be placed at the line with the closing function brace (based on my past experience when I was looked into this (checking raw reports with line numbers)). I'd suggest to run coverage report in terminal and examine PHPUnit-generated html report -- it may give you some additional info/clear things up a bit.

As for "jump to first uncovered line" -- try Alt+Shift+Down (that's on Windows using Default keymap). Or via small popup tool window when clicking on coverage marker in the gutter area:

Comment actions Permalink


I did as you said and found these lines. Some of them were, as you said, missing return statements.

One weirdly was in a folded method and when a method is folded the gutter color represents if the method has been hit at all(method body coverage doesn't matter), so when I unfolded, red gutter revealed.


Please sign in to leave a comment.