Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing phpunit随机重启测试_Unit Testing_Symfony_Phpunit - Fatal编程技术网

Unit testing phpunit随机重启测试

Unit testing phpunit随机重启测试,unit-testing,symfony,phpunit,Unit Testing,Symfony,Phpunit,我正在尝试使用PHPUnit测试我的symfony2应用程序。我得到了一个项目,其中一切都按预期工作,但在我的另一个项目中,我有一个奇怪的行为,PHPUnit要么在所有测试结束时随机停止执行测试套件,要么在完成测试套件并编写代码覆盖率后重新启动测试。其他时候它运行正常 下面是一些输出,用于显示正在发生的事情(测试正在一次又一次地重新启动): 以下是执行所有测试后重新启动测试套件的示例: PHPUnit 3.6.10 by Sebastian Bergmann. Configuration re

我正在尝试使用PHPUnit测试我的symfony2应用程序。我得到了一个项目,其中一切都按预期工作,但在我的另一个项目中,我有一个奇怪的行为,PHPUnit要么在所有测试结束时随机停止执行测试套件,要么在完成测试套件并编写代码覆盖率后重新启动测试。其他时候它运行正常

下面是一些输出,用于显示正在发生的事情(测试正在一次又一次地重新启动):

以下是执行所有测试后重新启动测试套件的示例:

PHPUnit 3.6.10 by Sebastian Bergmann.

Configuration read from C:\workspace\cllctr\app\phpunit.xml

................................................................. 65 / 83 ( 78%)
..................

Time: 01:29, Memory: 53.25Mb

OK (83 tests, 145 assertions)

Writing code coverage data to XML file, this may take a moment.

Generating code coverage report, this may take a moment.
PHPUnit 3.6.10 by Sebastian Bergmann.

Configuration read from C:\workspace\cllctr\app\phpunit.xml

................................................................. 65 / 83 ( 78%)
............PHPUnit 3.6.10 by Sebastian Bergmann.
因为我的另一个项目运行时没有任何问题,所以我的代码中一定有问题。但我不知道是什么触发了这种行为!日志没有显示任何意外/奇怪的内容

编辑


昨天,我注意到一些奇怪的事情:我决定从MongoDB切换到MySQL,因为一些不相关的原因。转换完成后,所有测试都会毫无问题地运行。我试了很多次,但我再也无法复制它了。由于这只发生在我的功能测试中,我倾向于认为问题在于我的WebTestCase类,它运行一些命令来清除和重建数据库。也许也使用MongoDB的人可以重现这种行为?

我建议检查数据库服务器连接限制和池

例如,如果您的最大连接限制为100个,而某些测试使连接处于打开状态(“泄漏”),那么您就达到了该限制

这也解释了为什么有时候它可以工作,有时候它会达到极限,因为您的数据库可以同时处理其他任务,所以有时候您达到了极限,有时候在没有其他运行的情况下,您可以成功地运行测试


检查持续的网络连接和其他外部资源。

看起来它总是发生在同一个地方,65/83。你能找出它要进行的测试吗?运行时尝试使用
--verbose
选项。65/83表示在第1行中,执行了65个测试(每个点都是一个测试)。在第二行中,您看到执行的测试的数量不一样,所以我怀疑这是一个失败的测试。由于测试有时工作,有时循环,我怀疑这是因为一个测试。但我会进一步调查!我的错!我的脑子里确实有这种知识。这里有一个问题-您是否在一个独立的PHP进程中运行每个测试?这可能是导致这种不寻常活动的原因。我们一直使用与您相同的PHPUnit版本,并且没有看到任何像您看到的那样疯狂的东西
phpunit--debug
将显示它正在运行的测试。
phpunit--testdox
将显示测试名称,而不是点。
PHPUnit 3.6.10 by Sebastian Bergmann.

Configuration read from C:\workspace\cllctr\app\phpunit.xml

................................................................. 65 / 83 ( 78%)
..................

Time: 01:29, Memory: 53.25Mb

OK (83 tests, 145 assertions)

Writing code coverage data to XML file, this may take a moment.

Generating code coverage report, this may take a moment.
PHPUnit 3.6.10 by Sebastian Bergmann.

Configuration read from C:\workspace\cllctr\app\phpunit.xml

................................................................. 65 / 83 ( 78%)
............PHPUnit 3.6.10 by Sebastian Bergmann.