[英]PHPUnit + symfony2: Excesive logging
我正在使用PHPUnit在使用symfony開發的Web應用程序上運行單元測試和功能測試。
每次我運行PHP Functional測試時,都會收到如此形式的大量日志消息:
[exec] [2013-11-22 12:42:05] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\TestSessionListener::onKernelRequest". [] {"uid":"58329be"}
[exec] [2013-11-22 12:42:05] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest". [] {"uid":"58329be"}
[exec] [2013-11-22 12:42:05] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest". [] {"uid":"58329be"}
[exec] [2013-11-22 12:42:05] event.DEBUG: Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest". [] {"uid":"58329be"}
...和其他一些堆棧跟蹤,即使測試通過了。
這是我的Ant Build腳本中的目標:
<macrodef name="RunPHPUnitSuite">
<attribute name="suite" />
<sequential>
<exec executable="php" failOnError="true" dir="${base.dir}">
<arg value="C:\someDir\phpunit.phar" />
<arg value="-c" />
<arg value="symfony2\app" />
<arg value="--testsuite" />
<arg value="@{suite}" />
</exec>
</sequential>
</macrodef>
<target name="PHPUnitTests" depends="delete_test_reports">
<RunPHPUnitSuite suite="UnitTests" />
<replace file="${testReports.dir}\phpunit.xml"
token='testsuite name="UnitTests"'
value='testsuite name="PHP"' />
<replaceregexp file="${testReports.dir}\phpunit.xml"
match='testsuite name="(\w+\\)+'
replace='testsuite name="'
byline="true" />
<replaceregexp file="${testReports.dir}\phpunit.xml"
match='class="(\w+\\)+'
replace='classname="PHPUnitTests.'
byline="true" />
<move file="${testReports.dir}\phpunit.xml"
tofile="${teamcityReports.dir}\php_unit_tests.xml" />
</target>
如何降低消息傳遞水平? 最佳輸出將是我通過PHP單元測試獲得的輸出
WebApp.PHPUnitTests:
[exec] PHPUnit 3.7.19 by Sebastian Bergmann.
[exec]
[exec] Configuration read from C:\Work\Software\WebApp\symfony2\app\phpunit.xml.dist
[exec]
[exec] ............................................................... 63 / 148 ( 42%)
[exec] ............................................................... 126 / 148 ( 85%)
[exec] ......................
[exec]
[exec] Time: 2 seconds, Memory: 12.00Mb
[exec]
[exec] ←[30;42m←[2KOK (148 tests, 266 assertions)
[exec] ←[0m←[2K
[move] Moving 1 file to C:\Work\Software\TestReports\
BUILD SUCCESSFUL
Total time: 3 seconds
將config.yml中的登錄操作級別提高為“錯誤”或“嚴重”會減少日志記錄的數量,但是對於開發而言,它們可能很有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.