64

Is there a more official way to force a phpunit failure than $this->assertTrue(false)?

Parris Varney
  • 10,663
  • 12
  • 44
  • 71

3 Answers3

108

I believe this should work within a test case:

$this->fail('Message');
rr.
  • 6,114
  • 8
  • 37
  • 43
3

Another way to do it (especially helpful when writing a testing tool) would be:

use PHPUnit_Framework_ExpectationFailedException as PHPUnitException;

try {
    // something here
} catch (SpecificException $e) {
    // force a fail:
    throw new PHPUnitException("This was not expected.");
}
Jannie Theunissen
  • 21,664
  • 18
  • 85
  • 111
0

Yes, theres a way,

$this->fail("your message");

if you want to see the page u have failed than

print_r(getResponse()->getContent());
Arpan Buch
  • 1,220
  • 4
  • 18
  • 41