php - Getting More Context Around PHPUnit Test Failures -


in phpunit, let's this:

$this->asserttrue( $some_variable == "foo" ); 

when run tests code in failing state, phpunit tells me: failed asserting false true. fine , good, , can track down why test failing. but...

i'm wondering if there way phpunit display more context me when test fails. example, possible phpunit output like: failed asserting false true. when test ran $some_variable equal "bar". allow me more track down why test failed.

i'd love if see context right in cli. there setting can apply phpunit make happen?

using asserttrue

the asserttrue method has second parameter, can specify message assertion should throw when assertion negative:

$this->asserttrue($somevariable == "foo", '$somevariable should have been "foo"') 

using specialized assertion functions

phpunit offers myriad of specialized assertions (for equality, identity, array elements , many more), produce reasonable error messages. have @ documentation.

$this->assertequals("foo", $somevariable); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -