问题描述:
PHPUnit 4.3.1 by Sebastian Bergmann.
Configuration read from /full/path/to/configuration.xml
R
Time: 2.65 seconds, Memory: 11.50Mb
OK, but incomplete, skipped, or risky tests! Tests: 1, Assertions: 1, Risky: 1. Done.
同时:
Risky Test: 测试代码或被测试代码没有(仅)关闭其自己的输出缓冲区
我的PHP版本是5.4。
如文档所述(https://phpunit.de/manual/current/en/strict-mode.html),这只适用于PHPUnit的严格模式设置。
PHPUnit在执行测试时可以执行额外的检查。除了对各种严格模式检查的细粒度控制(参见下面),您可以使用--strict命令行选项或在PHPUnit的XML配置文件中设置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>
我之前使用过一个更短的配置,它可以得到同样的结果。
<phpunit
beStrictAboutOutputDuringTests="false"
strict="false"
colors="false">
</phpunit>