It seems to have been an issue with the versions of phpunit and its dependencies. I ran an update on phpunit and now it is generating the coverage reports successfully. I am now using PHP_CodeCoverage 1.2.16, PHP 5.4.3 and PHPUnit 3.7.32.
PHPUnit Code coverage not generating reports correctly
-
14-10-2022 - |
Question
My phpunit xml:
<phpunit bootstrap="bootstrap.php">
<testsuites>
<testsuite name="Phase Unit Tests">
<directory>./Phase</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">Api/app/library</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/report" charset="UTF-8"
highlight="false" lowUpperBound="35" highLowerBound="70"/>
<log type="testdox-html" target="build/testdox.html"/>
</logging>
</phpunit>
My test run successfully and I am not getting errors. I have checked for any DIE()
and EXIT
calls and did not find any in my code. When I look at my report it is just the empty folders with no files being scanned.
I am using PHP_CodeCoverage 1.2.7 using PHP 5.4.3 and PHPUnit 3.7.13 on Windows 8 with Wamp server 2.2
Ok so I wrote a small thing to test PHPUnit coverage reporting... Below is my classes:
/**
* test
*/
class Application
{
public $testprop;
function __construct()
{
$this->testprop = "Stuff";
}
}
/**
* Tests for the application class
*/
class ApplicationTest extends PHPUnit_Framework_TestCase
{
public function testRunTheThing()
{
$app = new Application();
$this->assertEquals($app->testprop, 'Stuff');
}
}
I run the following in my command prompt:
phpunit --coverage-html report ApplicationTest.php
The test passes but the code coverage report generated is of the composer ClassLoader file.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow