PHPUnit assertions do throw a PHPUnit\Framework\ExpectationFailedException exception when they fail. This is how PHPUnit internally
notices when assertions within testcases fail. However, if such an exception type or one of its parent types is captured within a try-catch block and
not rethrown, PHPUnit does not notice the assertion failure.
This check raises an issue on assertions within the try body of a try-catch block that do catch exceptions of the type
PHPUnit\Framework\ExpectationFailedException, PHPUnit\Framework\AssertionFailedError, or Exception, and do not handle the
variable holding the exception.
Noncompliant code example
public function testA() {
try {
assertTrue(getValue()); // Noncompliant
} catch (\PHPUnit\Framework\ExpectationFailedException $e) {
}
}
Compliant solution
public function testB() {
try {
assertTrue(getValue()); // Compliant
} catch (\PHPUnit\Framework\ExpectationFailedException $e) {
assertEquals("Some message", $e->getMessage());
}
}