PHPUnit总是返回JSON对象

时间:2017-06-14 20:42:39

标签: php json phpunit

执行php phpunit.phar时,我总是以下列格式得到结果:

PHPUnit 4.8.10 by Sebastian Bergmann and contributors.
Warning:              The Xdebug extension is not loaded
                                No code coverage will be generated.

{
    "event": "suiteStart",
    "suite": "CodeIgniter Application Test Suite",
    "tests": 3
}{
    "event": "suiteStart",
    "suite": "Welcome_test",
    "tests": 3
}{
    "event": "testStart",
    "suite": "Welcome_test",
    "test": "Welcome_test::test_index"
}{
    "event": "test",
    "suite": "Welcome_test",
    "test": "Welcome_test::test_index",
    "status": "pass",
    "time": 0.020705938339233,
    "trace": [],
    "message": "",
    "output": ""
}.{
    "event": "testStart",
    "suite": "Welcome_test",
    "test": "Welcome_test::test_method_404"
}{
    "event": "test",
    "suite": "Welcome_test",
    "test": "Welcome_test::test_method_404",
    "status": "pass",
    "time": 0.0022480487823486,
    "trace": [],
    "message": "",
    "output": ""
}.{
    "event": "testStart",
    "suite": "Welcome_test",
    "test": "Welcome_test::test_APPPATH"
}{
    "event": "test",
    "suite": "Welcome_test",
    "test": "Welcome_test::test_APPPATH",
    "status": "pass",
    "time": 0.00034213066101074,
    "trace": [],
    "message": "",
    "output": ""
}.

Time: 821 ms, Memory: 10.00Mb

OK (3 tests, 3 assertions)

我一直在尝试使用https://phpunit.de/manual/3.7/en/textui.html中列出的多个命令行选项,但都没有。

我需要以常规格式显示结果,该格式仅显示以下格式的结果:

PHPUnit 4.8.10 by Sebastian Bergmann and contributors. Starting test 'Welcome_test::test_index' .

Starting test 'Welcome_test::test_method_404' .

Starting test 'Welcome_test::test_APPPATH' .

Time: 1.23 seconds, Memory: 13.25Mb OK (3 tests, 3 assertions)

在JSON中显示整个执行过程的格式使我的VisualPHPUnit中断。 我的phpunit.xml如下:

<phpunit bootstrap="./Bootstrap.php" backupGlobals="true" colors="true">
    <testsuites>
        <testsuite name="CodeIgniter Application Test Suite">
            <directory suffix="test.php">./</directory>
            <exclude>./_ci_phpunit_test/</exclude>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist>
            <directory suffix=".php">../controllers</directory>
            <directory suffix=".php">../models</directory>
            <directory suffix=".php">../views</directory>
            <directory suffix=".php">../libraries</directory>
            <directory suffix=".php">../helpers</directory>
            <directory suffix=".php">../hooks</directory>
        </whitelist>
    </filter>
    <logging>
        <log type="coverage-html" target="build/coverage"/>
        <log type="coverage-clover" target="build/logs/clover.xml"/>
        <log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
    </logging>
    <!-- This is required for VPU to work correctly -->
    <listeners>
        <listener class="PHPUnit_Util_Log_JSON"/>
    </listeners>
</phpunit>

任何解决方案/建议?这是错误还是配置问题?

由于

1 个答案:

答案 0 :(得分:0)

一般来说,PHPUnit_Util_Log_JSON听众负责:

<listeners>
    <listener class="PHPUnit_Util_Log_JSON"/>
</listeners>

如果您需要有关VisualPHPUnit的帮助,我可以尝试,但可能需要一些有关您的配置的详细信息。

它是你真正需要的工具还是一个很好的补充?