【发布时间】:2015-02-04 10:52:28
【问题描述】:
问题:为什么 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 可以在执行测试时执行额外的检查。在 除了对各种严格模式的细粒度控制 检查(见下文)您可以使用 --strict 命令行选项或设置 PHPUnit 的 XML 配置文件中的 strict="true" 以启用所有 他们。
-
测试执行期间的输出
PHPUnit 在测试期间可以严格控制输出。这个检查可以 通过在命令行上使用 --disallow-test-output 选项启用 或者通过在 PHPUnit 的 XML 中设置 beStrictAboutOutputDuringTests="true" 配置文件。
发出输出的测试,例如通过在任一 测试代码或被测试的代码,在这个检查时会被标记为有风险的 已启用。
我相信,我没有激活严格模式。我的命令行是“/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>
【问题讨论】:
-
你碰巧解决了这个问题吗?
-
我这样做的目的是让报告的问题消失,但不是我的初衷是让 PHPUnit 忽略该问题。问题出在我使用的一个库上,我找到了解决问题的方法:help.slimframework.com/discussions/problems/…
-
我在这里回答了同样的问题stackoverflow.com/questions/38400305/…
-
我在这里回答了同样的问题stackoverflow.com/questions/38400305/…
标签: php unit-testing phpunit