PHPUnit抑制忽略的消息

时间:2016-11-29 17:39:16

标签: php phpunit

有没有办法抑制打印到cli的消息

例如,我们有一些等待PHPUnit 5.5。*的测试(我们计划很快更新)。但是这些测试中的每一个都打印出来

PHPUnit 5.5 (or later) is required.

是否有cli命令来过滤掉这些?我在这里找不到https://phpunit.de/manual/current/en/textui.html

修改 正在运行的命令只是phpunit --configuration /path/to/config.xml

看起来像:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
     backupStaticAttributes="false"
     bootstrap="site-config.php"
     colors="true"
     convertErrorsToExceptions="true"
     convertNoticesToExceptions="true"
     convertWarningsToExceptions="true"
     processIsolation="false"
     stopOnFailure="false">
  <testsuites>
    <testsuite name="Application Test Suite">
        <directory suffix="Test.php">./tests</directory>
    </testsuite>
  </testsuites>
  <filter>
    <whitelist processUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">./app</directory>
        <directory suffix=".php">./classes</directory>
    </whitelist>
  </filter>
</phpunit>

回复评论: 这些警告肯定来自PHPUnit,因为使用了“跳过/不完整测试”中的@requires而导致的警告。文档: https://phpunit.de/manual/current/en/incomplete-and-skipped-tests.html

1 个答案:

答案 0 :(得分:0)

它在phpunit.xml中必须具有verbose="true",因为默认情况下PHPUnit不打印verbose消息。检查以下命令以查看其他命令。

$ phpunit --no-configuration /path/to/tests/dir

PHPUnit 5.7.27 by Sebastian Bergmann and contributors.

S                                                1 / 1 (100%)

Time: 93 ms, Memory: 6.00MB

OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 0, Skipped: 1.

-

$ phpunit --verbose --no-configuration /path/to/tests/dir

PHPUnit 5.7.27 by Sebastian Bergmann and contributors.

S                                                 1 / 1 (100%)

Time: 93 ms, Memory: 6.00MB

There was 1 skipped test:

1) ExampleTest::testPHPUnitRequire
PHPUnit >= 7.2 is required.

OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 0, Skipped: 1.
相关问题