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'?
A test that is annotated with @covers and executes code that is not listed using a @covers or @uses annotation will be marked as risky when this check is enabled.
A test that emits output, for instance by invoking print in either the test code or the tested code, will be marked as risky when this check is enabled.
The <testsuite> Element.
You can run all the tests in a directory using the PHPUnit binary installed in your vendor folder. You can also run a single test by providing the path to the test file.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With