我正在为一个网站实施一些测试。
在一次特定的测试中,出现了这样的结果:
{
"event": "test",
"suite": "Example_V_test",
"test": "Example_V_test::test_3",
"status": "error",
"time": 13.469105958939,
"trace": [
{
"file": "\/opt\/lampp\/htdocs\/buy\/application\/tests\/phpunit.phar",
"line": 569,
"function": "main",
"class": "PHPUnit_TextUI_Command",
"type": "::"
}
],
"message": "Risky Test: Test code or tested code did not (only) close its own output buffers",
"output": ""
}R 3 / 3 (100%)
Time: 25.76 seconds, Memory: 59.25MB
There was 1 risky test:
1) Example_V_test::test_3
Test code or tested code did not (only) close its own output buffers
/opt/lampp/htdocs/buy/application/tests/phpunit.phar:569
OK, but incomplete, skipped, or risky tests!
我的问题是:如何找到导致此“问题”的代码行?
如果 PHPUnit 检测到测试方法结束时的输出缓冲级别与开始时的级别不同,则会报告该消息。这是因为它使用自己的输出缓冲区并检查测试是否不产生输出。
因为 PHPUnit 中没有选项可以忽略这一点,所以您需要找到代码中的输出缓冲已启动但未结束(或结束太多)的原因并修复该问题。
这可能真的很难实现,因为没有提示输出缓冲从哪里开始,但您可以对源代码(和库)使用全文搜索来识别候选者。然后查找异常,这可能会破坏正常的程序流程,从而阻止ob_end_flush()
(或类似)被调用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)