Hide output during PHPUnit test execution

前端 未结 1 2006
余生分开走
余生分开走 2020-12-20 12:11

I have some var_dumps in my php code (i understand what there must be none in the end, but still), and while tests are running they outputs non necessary information to cons

相关标签:
1条回答
  • 2020-12-20 12:32

    You can set the setOutputCallback to a do nothing function. The effect is to suppress any output printed in the test or in the tested class.

    As Example:

    namespace Acme\DemoBundle\Tests;
    
    
    class NoOutputTest extends \PHPUnit_Framework_TestCase {
    
        public function testSuppressedOutput()
        {
            // Suppress  output to console
            $this->setOutputCallback(function() {});
            print '*';
            $this->assertFalse(false, "Don't see the *");
        }
    
    }
    

    You can find some reference in the doc

    Hope this help

    0 讨论(0)
提交回复
热议问题