Search code examples
phpphpunitcode-coverage

PHPUnit code coverage reports SOME files as they have no code in it (and so report a 0/0 Line 100% coverage)


I've been searching a solution for a while but couldn't find any.

I do some code-coverage on my PHP application and it works fine except for a couple of files that PHPUnit seems to consider as empty (I mean, as there was no line of code) even though they are not empty (each one contain hundreds lines).

I can see the class and its methods but each function is considered to have 0 line (it says 0/0 100% coverage). If I try to click on function or classes names, I usually see the code but not for these problematic classes.

I'd like to post an image but as I'm a new user I unfortunately can't.

Anyone got the same issue ?

Edit: Here is a sample class that has the issue:

1 http://img43.imageshack.us/img43/9127/screenshot1aig.png

Edit after solution found (2): I removed source code since it was not the problem.


Solution

  • I found a workaround guys. I did as proposed by cweiske (which I should have done earlier) and shrinked until the phpunit code coverage would work. But surprise, it never worked even though I left only one single method.

    I created another file "Foo.php", containing the same content as PlayersManager (almost empty, only one function).

    An Foo.php was covered perfectly ! I copied the whole file I had from PlayersManager into Foo.php, ran the code coverage and it was working perfectly.

    Just to prove I'm not crazy, I recopied the code in PlayersManager and retried: PlayersManager coverage was still 100% with 0 line of code.

    I deleted PlayersManager.php and renamed Foo.php PlayersManager.php, reran the coverage and it works !

    Is phpunit keeping some cache or something like that !?

    Anyway the workaround will make it for other problematic files in future, but just wondering !

    Thanks for help !