2017-06-14 162 views
0

當執行PHP phpunit.phar我一直都想與下面的格式結果:PHPUnit的總是返回JSON對象

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> 

任何解決方案/建議?這是一個錯誤還是配置問題?

感謝

+0

你能分享你用來運行套件的配置和命令嗎? –

+0

@MateuszSip你的配置是什麼意思?對不起,我是PHPUnit的新手。如果你的意思是phpunit.xml,那麼我只是把它添加到問題中。我正在使用的命令是: php phpunit.phar 我也試過php phpunit.phar --debug,但它沒有工作。自從我在這裏呆了一段時間以來,我會很感激任何幫助。在此先感謝 – MrCujo

+1

看起來像'PHPUnit_Util_Log_JSON'那樣做。我在'VisualPHPUnit'版本庫中看不到它。 –

回答

0

一般來說,PHPUnit_Util_Log_JSON聽衆負責的是:

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

如果您需要關於VisualPHPUnit我可以嘗試一些幫助,但它可能需要有關配置的一些細節。

它是您真正需要的工具還是隻是一個很好的補充?

+0

好吧,這將是一個很好的補充。我試圖說服我的主管採用TDD,因此通過瀏覽器給他提供檢查結果的選項是完美的。你需要哪些關於配置的其他細節? – MrCujo