小编And*_*s B的帖子

PHPUnit - 为什么PHPUnit似乎在严格模式下运行?

问题:为什么PHPUnit似乎在严格模式下运行?

问题:

Sebastian Bergmann的PHPUnit 4.3.1.

配置从/full/path/to/configuration.xml读取

[R

时间:2.65秒,内存:11.50Mb

好的,但不完整,跳过或有风险的测试!测试:1,断言:1,风险:1.完成.

也:

危险测试:测试代码或测试代码没有(仅)关闭自己的输出缓冲区

我的PHP版本是5.4.

如文档(https://phpunit.de/manual/current/en/strict-mode.html)中所述,这似乎仅适用于PHPUnits的严格模式设置.

PHPUnit可以在执行测试时执行其他检查.除了对各种严格模式检查(见下文)的细粒度控制之外,您可以在PHPUnit的XML配置文件中使用--strict命令行选项或set strict ="true"来启用所有这些选项.

-

测试执行期间的输出

PHPUnit在测试期间可以严格控制输出.可以通过在命令行上使用--disallow-test-output选项或在PHPUnit的XML配置文件中设置beStrictAboutOutputDuringTests ="true"来启用此检查.

发出输出的测试(例如通过在测试代码或测试代码中调用print)将在启用此检查时标记为有风险.

我相信,我没有激活严格模式.我的命令行是"/ usr/bin/php/usr/bin/phpunit --colors --bootstrap /full/path/to/bootstrap.php --configuration/full/path/to/configuration.xml/full/path /to/Test.php".我还使用了" https://phpunit.de/manual/current/en/appendixes.configuration.html "中提供的配置.

<phpunit
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.3/phpunit.xsd"
   backupGlobals="true"
   backupStaticAttributes="false"
   cacheTokens="false"
   colors="false"
   convertErrorsToExceptions="true"
   convertNoticesToExceptions="true"
   convertWarningsToExceptions="true"
   forceCoversAnnotation="false"
   mapTestClassNameToCoveredClassName="false"
   printerClass="PHPUnit_TextUI_ResultPrinter"
   processIsolation="false"
   stopOnError="false"
   stopOnFailure="false"
   stopOnIncomplete="false"
   stopOnSkipped="false"
   testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
   timeoutForSmallTests="1"
   timeoutForMediumTests="10"
   timeoutForLargeTests="60"
   strict="false"
   verbose="false">
</phpunit>
Run Code Online (Sandbox Code Playgroud)

我之前使用过这种配置的较短版本,提供了相同的结果.

<phpunit
   beStrictAboutOutputDuringTests="false"
   strict="false"
   colors="false">
</phpunit>
Run Code Online (Sandbox Code Playgroud)

php phpunit unit-testing

7
推荐指数
1
解决办法
2654
查看次数

标签 统计

php ×1

phpunit ×1

unit-testing ×1