I'm using PHPUnit (3.6.7) to test and provide code coverage reports on my application, everything is set-up and working as expected.

I have complete coverage for all of the code except for my interfaces, even though I have tests that for classes that implement the interfaces. The report just states that the interface was not executed

Is there a way to cover the interfaces? Or is it a case of telling PHPUnit to ignore them for code coverage?

Thanks, Paul

link|improve this question
feedback

3 Answers

up vote 2 down vote accepted

You can specify that tests for a concrete class cover methods from parent abstract classes/interfaces.

See Specifying Covered Methods section in Code Coverage Analysis chapter in the manual.

In the same chapter you'll also find ways to ignore blocks of code or entire files from code coverage analysis.

link|improve this answer
Perfect! Thank you. For anyone else that come across this, you need @covers Class_Name<extended> in you test class doc block – Paul Dixon Jan 16 at 15:27
feedback

Just as an additional answer:

The next release of PHPUnit (3.7.) will ignore all interfaces for coverage by default.

So it will not necessary to use any sort of includes or //@codeCoverageIgnore ways to work around then.

link|improve this answer
feedback

Interfaces contain no executable code, so there's nothing there to test.

link|improve this answer
I'm not trying to test them directly, though they do get used with assertInstanceOf(), I just want them in the code coverage as they are being "used" – Paul Dixon Jan 16 at 14:57
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.