jacmoe
(Jacob Moena)
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.
jacmoe
(Jacob Moena)
2
To answer my own question:
use Codeception\Util\Debug;
and:
$issue->validate();
Debug::debug($issue->errors);
samdark
(Alexander Makarov)
3
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) );
jacmoe
(Jacob Moena)
5
That is neatly all in one line. I like that Dana