phpunit - Help needed about risky tests

南楼画角 提交于 2020-01-14 08:35:31

问题


i'm implementing some tests for a site. In a particular test, this result occurred:

{
"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!

My question is this: how to find the line of code that cause this 'issue'?


回答1:


The message is reported if PHPUnit detects that the output buffering level at the end of a test method is different from the level at the beginning. This is due to the fact that it uses its own output buffer and checks that the test produces no output.

Because there is no option in PHPUnit to ignore this, you need to find the reason why the output buffering in your code was started but not ended (or ended too much) and fix that.

That might be really difficult to achieve because there is no hint, where output buffering is started, but you could use a full-text search on your source code (and libs) to identify candidates. Then look for Exceptions, which might break the normal program flow and so prevent ob_end_flush() (or similar) to be called.



来源:https://stackoverflow.com/questions/38400305/phpunit-help-needed-about-risky-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!