phpunit-有关风险测试的帮助 [英] phpunit - Help needed about risky tests

查看:87
本文介绍了phpunit-有关风险测试的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为网站实施一些测试. 在特定的测试中,发生了以下结果:

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'?

推荐答案

如果PHPUnit检测到测试方法结束时的输出缓冲级别与开始时的级别不同,则会报告此消息.这是因为它使用自己的输出缓冲区并检查测试是否没有输出.

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.

由于PHPUnit中没有选项可以忽略这一点,因此您需要找出代码中的输出缓冲已开始但未结束(或结束太多)的原因并加以解决.

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.

这可能真的很难实现,因为没有提示,即开始输出缓冲,但是您可以在源代码(和库)上使用全文本搜索来识别候选对象.然后查找异常,这可能会中断正常的程序流程,并因此阻止调用ob_end_flush()(或类似名称).

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.

这篇关于phpunit-有关风险测试的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆