简体   繁体   中英

PHPUnit + symfony2: Excesive logging

I am using PHPUnit to run Unit tests and Functional Tests on a Web app developed with symfony.

Everytime I run the PHP Functional tests, I get an insane amount of logging messages, of this form:

 [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"}

...and some other stack traces, even though the tests pass.

This is the target in my Ant Build Script:

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

How could I cut down the level of messaging? The optimum output would be the one I get with the PHP Unit testing

 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中的登录操作级别提高为“错误”或“严重”会减少日志记录的数量,但是对于开发而言,它们可能很有用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM