PHPUnit代码覆盖率无法正确生成报告

时间:2014-02-20 11:51:36

标签: php phpunit code-coverage

我的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>

我的测试运行成功,我没有收到错误。我已检查过任何DIE()EXIT来电,但在我的代码中未找到任何内容。当我查看我的报告时,它只是没有文件被扫描的空文件夹。

我在Windows 8上使用PHP 5.4.3和PHPUnit 3.7.13使用PHP_CodeCoverage 1.2.7和Wamp server 2.2

好的,所以我写了一个小东西来测试PHPUnit报道报告......下面是我的课程:

/**
*   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');
    }
}

我在命令提示符下运行以下命令:

phpunit --coverage-html report ApplicationTest.php

测试通过,但生成的代码覆盖率报告是作曲家ClassLoader文件。

1 个答案:

答案 0 :(得分:1)

phpunit及其依赖项的版本似乎是一个问题。我在phpunit上运行了更新,现在它正在成功生成覆盖率报告。我现在使用PHP_CodeCoverage 1.2.16,PHP 5.4.3和PHPUnit 3.7.32。

相关问题