Saturday, May 26, 2007

assertSame() & phpunit

Take a look at enhancing assertSame() error messages for phpunit.

This is one of my most frequent gotchas, usually happening about once a fortnight. It drives me insane.

Basically, I do:

$expected = "Catfish";
$actual = SomeComplicatedConvolutedClass::method(); //returns "Catfish"
$this->assertSame($excepted, $actual);


and get an error message telling me that null isn't the same as Catfish. That's perfectly good, except I haven't clicked that the bug is my typo, not in SomeComplicatedConvolutedClass::method()

What a pain!

No comments: