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?
The easiest way to exclude code from code coverage analysis is to use ExcludeFromCodeCoverage attribute. This attribute tells tooling that class or some of its members are not planned to be covered with tests. EditFormModel class shown above can be left out from code coverage by simply adding the attribute.
Code Coverage Analysis. Wikipedia: In computer science, code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite.
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.
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.
Interfaces contain no executable code, so there's nothing there to test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With