简体   繁体   English

无法在PHPStorm中运行PHPUnit测试

[英]Unable to run PHPUnit test in PHPStorm

I have a test suite running on PHPUnit using the PHPStorm IDE. 我有一个使用PHPStorm IDE在PHPUnit上运行的测试套件。 But, one of the tests used to fail due to the following issue, 但是,由于以下问题,其中一项测试曾经失败了,
PHP Warning: Cannot modify header information - headers already sent by ...

I managed fixed that by adding the @runInSeparateProcess annotation. 我通过添加@runInSeparateProcess批注来解决此问题。

I was able to run all the tests successfully in the terminal. 我能够在终端中成功运行所有测试。 But when I try to run the tests using the PHPStorm IDE, I end up getting the following error message - 但是,当我尝试使用PHPStorm IDE运行测试时,最终得到以下错误消息-

PHPUnit_Framework_Exception : PHPUnit 4.2.5 by Sebastian Bergmann.

Usage: phpunit [options] UnitTest [UnitTest.php]
       phpunit [options] <directory>
Code Coverage Options:

--coverage-clover <file>  Generate code coverage report in Clover XML format.

...(basically prints out the output of phpunit --help)

This is seen only while running the same test that failed earlier with the header error message. 仅在运行先前因标题错误消息而失败的相同测试时,才能看到此结果。

Please assist me to fix this issue. 请协助我解决此问题。 Any help will be greatly appreciated. 任何帮助将不胜感激。

Thanks! 谢谢!

Finally managed to fix it! 终于设法解决了! I removed the @runInSeparateProcess annotation for the test that was failing and also the --stderr option in the run configurations. 我删除了@runInSeparateProcess的测试的@runInSeparateProcess批注以及运行配置中的--stderr选项。 Instead, I added stderr="true" option in the phpunit tag present in the phpunit.xml and it worked. 相反,我添加stderr="true"的存在于phpunit.xml PHPUnit的标签选项,它的工作。 Strange. 奇怪。

Thank you Ian Bytchek for your time and effort. 感谢Ian Bytchek的时间和精力。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM