Silent testing

How do you get Yii to generate error messages that you can actually see while testing?

I get a fail in this code:


$this->assertTrue($issue->validate(), 'Issue should validate');

It would be nice to know why the assertion was not true.

I am running codecept run --debug

Or, should I debug my code and then test ?

What’s the point of writing tests, then ?

If Yii is silent, I mean.

To answer my own question:


use Codeception\Util\Debug;



and:


    	$issue->validate();

    	Debug::debug($issue->errors);



An alternative is to pass a message to assertTrue() as third argument. Then it would be there on fail.

I tend to do:


$this->assertTrue($issue->validate(), 'Issue should validate: '.VarDumper::dump( $issue->errors) );

That is neatly all in one line. I like that Dana :)