How to output in CLI during execution of PHP Unit tests?

后端 未结 18 1675
旧时难觅i
旧时难觅i 2020-11-30 18:01

When running a PHPUnit test, I would like to be able to dump output so I can debug one or two things.

I have tried the following (similar to the PHPUnit Manual examp

18条回答
  •  没有蜡笔的小新
    2020-11-30 18:12

    In short, phpunit supresses STDOUT. It writes to STDERR by default, unless you add --verbose or --debug . You can do one of those things:

    • print your debug output to STDERR instead
    • var_dump your debug as usual but add --verbose to the phpunit command line
    • var_dump your debug as usual but add a line ob_flush(); beneath it
    • use the correct commands in phpunit for testing exactly what you're trying to test here

    Obviously, the last thing is the Good Thing to do, and the rest are quick temporary hacks.

提交回复
热议问题