Source:
public void handleExceptionsDuringTest(TestErrorLog testErrorLog) { validated = true; checkShutdown(); if (!exceptionMap.isEmpty()) { List<Clue> clues = resources.values().stream() .filter(Investigable.class::isInstance) .peek(cloudbreakTestDto -> { try { cloudbreakTestDto.refresh(); } catch (Exception e) { LOGGER.warn("Failed to refresh {}, continue with using its last known state.", cloudbreakTestDto, e); } }) .map(Investigable.class::cast) .map(Investigable::investigate) .filter(Objects::nonNull) .collect(Collectors.toList()); String errorMessage = errorLogMessageProvider.getMessage(exceptionMap, clues); testErrorLog.report(LOGGER, errorMessage); ITestResult testResult = Reporter.getCurrentTestResult(); Throwable testFailException = errorLogMessageProvider.getException(exceptionMap); if (testFailException != null) { testResult.setThrowable(testFailException); testResult.setTestName(getTestMethodName().get()); testResult.setStatus(2); String methodName = testResult.getName(); int status = testResult.getStatus(); String testFailureType = testResult.getThrowable().getCause().getClass().getName(); String message = testResult.getThrowable().getCause().getMessage() != null ? testResult.getThrowable().getCause().getMessage() : testResult.getThrowable().getMessage(); String className = TestContext.class.getName(); LOGGER.info("[{}] Failed test results are: Test Case: | Status: | Failure Type: | Message: {}", className, methodName, status, testFailureType, message); testResult.getTestContext().setAttribute(OUTPUT_FAILURE_TYPE, testFailureType); testResult.getTestContext().setAttribute(OUTPUT_FAILURE, testResult.getThrowable()); } else { LOGGER.error("Test Context TestFailException is null! So cannot get the correct test fail result!"); } exceptionMap.clear(); } }

Target:
public void handleExceptionsDuringTest(TestErrorLog testErrorLog) { validated = true; checkShutdown(); if (!exceptionMap.isEmpty()) { List<Clue> clues = resources.values().stream() .filter(Investigable.class::isInstance) .peek(cloudbreakTestDto -> { try { cloudbreakTestDto.refresh(); } catch (Exception e) { LOGGER.warn("Failed to refresh {}, continue with using its last known state.", cloudbreakTestDto, e); } }) .map(Investigable.class::cast) .map(Investigable::investigate) .filter(Objects::nonNull) .collect(Collectors.toList()); String errorMessage = errorLogMessageProvider.getMessage(exceptionMap, clues); testErrorLog.report(LOGGER, errorMessage); ITestResult testResult = Reporter.getCurrentTestResult(); Throwable testFailException = errorLogMessageProvider.getException(exceptionMap); if (testFailException != null) { testResult.setThrowable(testFailException); testResult.setTestName(getTestMethodName().get()); testResult.setStatus(ITestResult.FAILURE); String methodName = testResult.getName(); int status = testResult.getStatus(); String testFailureType = testResult.getThrowable().getCause().getClass().getName(); String message = testResult.getThrowable().getCause().getMessage() != null ? testResult.getThrowable().getCause().getMessage() : testResult.getThrowable().getMessage(); LOGGER.info("Failed test results are: Test Case: | Status: | Failure Type: | Message: {}", methodName, status, testFailureType, message); testResult.getTestContext().setAttribute(methodName + OUTPUT_FAILURE_TYPE, testFailureType); testResult.getTestContext().setAttribute(methodName + OUTPUT_FAILURE, testResult.getThrowable()); } else { LOGGER.error("Test Context TestFailException is null! So cannot get the correct test fail result!"); } exceptionMap.clear(); } }