Silent testing

(Jacob Moen) #1

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.

(Jacob Moen) #2

To answer my own question:

use Codeception\Util\Debug;




(Alexander Makarov) #3

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

(Dana Luther) #4

I tend to do:

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

(Jacob Moen) #5

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