is it possible to use kind of 'soft assertion' that's allow continue running the test event if the assert fail?
The reason for the current behavior is that assertions throw exceptions when they fail. If you want to "continue running," you can use a try/catch block:
try {
$this->assertTrue(false);
}
catch (PHPUnit_Framework_AssertionFailedError $e) {
}
// continue running
Just make sure you re-throw the exception or call $this->fail() by the end of the test if an exception is raised.
this also works:
$this->expectException(Exception::class);
try {
$this->whateverThatGeneratesTheException...
} finally {
//run any code afterwards
}
Most helpful comment
The reason for the current behavior is that assertions throw exceptions when they fail. If you want to "continue running," you can use a
try/catchblock:Just make sure you re-throw the exception or call
$this->fail()by the end of the test if an exception is raised.