void (TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) { final TestExecutionResult.Status status = testExecutionResult.getStatus(); final Throwable throwable = testExecutionResult.getThrowable().orElse(null); if (status != TestExecutionResult.Status.FAILED) { return; } testIdentifier.getSource().map( testSource -> testSource instanceof MethodSource ms ? ms.getClassName() : testSource instanceof ClassSource cs ? cs.getClassName() : null ).ifPresent(className -> listener.addError(className, throwable)); }