I am running a series of PHPunit tests and have a controller that reports 100% coverage. However, only 5 out of 84 lines of code are green in the reach report.
I am wondering what factors can cause this problem?
One interesting point that can cause it is "indirect calls." This particular controller is the parent of a number of other controllers, and since many other objects inherit it, the code may be called elsewhere ... but then will it not turn green?
As the only method that turns green, is the method __construct.
I donβt know if this is enough to continue, but if someone has a little more knowledge about how Unit Testing determines coverage, I would like to hear it.
Edit in response to Gaurav comment:
Phpunit command line phpunit --configuration admin.xml
and admin.xml reads
<phpunit bootstrap="./admin/applications/admin/bootstrap.php" colors="true">
<testsuite name="AdminTestSuite">
<directory suffix=".php">./admin/applications/admin/</directory>
<directory suffix=".php">./admin/applications/shared/</directory>
</testsuite>
<filter>
<whitelist>
<directory suffix=".php">../admin/applications/admin/controllers</directory>
<directory suffix=".php">../admin/applications/shared/controllers</directory>
<directory suffix=".php">../admin/applications/shared/helpers</directory>
<directory suffix=".php">../admin/lib/controllers</directory>
<directory suffix=".php">../admin/lib/helpers</directory>
<directory suffix=".php">../admin/lib/models</directory>
<directory suffix=".php">../admin/lib/utils</directory>
</whitelist>
<blacklist>
<file>../dm_admin/applications/shared/controllers/DashboardController.php</file>
<directory suffix=".php">../admin/lib/crons</directory>
</blacklist>
</filter>
<logging>
<log type="coverage-html" target="/projects/ut/admin/" charset="UTF-8"
yui="true" highlight="true"
lowUpperBound="50" highLowerBound="80"/>
<log type="testdox-html" target="/projects/ut/admin/testdox.html" />
</logging>
</phpunit>
In response to jakenoble:
assistant reads 100% coverage

but inside we see

This continues for 1099 lines, with random green ... but not red.
source
share