0

I am getting a weird result when trying to create a code coverage report of my test.

I call this:

phpunit --coverage-html report tests/JSONTest.php

And get this:

PHPUnit 3.6.12 by Sebastian Bergmann.
.
Time: 0 seconds, Memory: 6.75Mb
OK (1 test, 1 assertion)
Generating code coverage report in HTML format ... done

My test looks like this:

<?php

require_once dirname(__FILE__) . "/../include/includeAllNecessaryFiles.php";

class JSONTest extends PHPUnit_Framework_TestCase {
    public function testBla() {
        $this->assertEquals("hallo", "hallo");
    }
}

The file includeAllNecessaryFiles.php has this content:

<?php
include '/usr/share/php/PHPUnit/Framework/TestCase.php';

function something(){

}

The report lists all directories of the php-files that have been used, but doesn't list any files. It displays a 100% coverage, 0 of 0 lines have been covered.

When I throw this out:

function something(){

}

The report works properly and shows exactly how many lines the test covers.

Does anybody have an idea?

Thanks in advance!

Ben

4

1 回答 1

1

我发现代码覆盖率报告并不总是 100% 准确。可能有很多原因。我曾经问过 Derick Rethans(Xdebug 的创建者)这个问题。他告诉我,同时使用 Zend Debugger 和 Xdebug(我倾向于这样做)已经知道可以减少行数。

我知道这没有多大帮助,但我只是想让你知道这是一个已知问题。

于 2013-04-30T18:50:48.483 回答