unit-testing - PHPUnit 输出带有 header 异常(--stderr 无结果)

标签 unit-testing zend-framework testing phpunit

使用 zend 和 phpunit 进行测试时。控制台上显示标题错误。 我发现错误:

Cannot modify header information - headers already sent by (output started at /usr/share/php/PHPUnit/Util/Printer.php:173)

我尝试按照某些主题中的说明进行调试 Is there a way test STDERR output in PHPUnit?PHPUnit output causing Zend_Session exceptions 。 但是当使用 --stderr 选项时,我找不到测试用例的一些输出和报告。 这是控制台上的输出:

root@ubuntu:/home/boingonline/www/testunit# phpunit --stderr
PHPUnit 3.5.15 by Sebastian Bergmann.

root@ubuntu:/home/boingonline/www/testunit# 

对于这个问题有什么想法吗?感谢您的所有回答。

最佳答案

这是一个bug in PHP 。每当输出某些内容时(即使在 CLI 上,这也是问题所在),您就不能再使用 header() 调用。

解决方法是使用 @runInSeparateProcess 进行测试的进程隔离.

关于unit-testing - PHPUnit 输出带有 header 异常(--stderr 无结果),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13875761/

相关文章:

django - 测试期间错误的 default_storage

unit-testing - 模拟框架如何工作?

php - Zend 框架 : preDispatch ACL plugin causes requests to non existent page to Access Denied instead of 404

php - 学说 2 和 zend paginator

c# - 使用数据源的 NUnit 数据驱动单元测试

php - PHP 内置的 filter_input 是否正常工作?

haskell - 测试 Main 模块中定义的 Haskell 代码

testing - Arquillian,(嵌入式)Glassfish 和 JMS : How to test a worker?

testing - Gradle 拒绝启动进程命令 'cmd'

C++/Visual Studio - 如何输出到测试输出窗口?