use of com.seleniumtests.reporter.info.LogInfo in project seleniumRobot by bhecquet.
the class SeleniumRobotTestListener method logThrowableToTestEndStep.
private void logThrowableToTestEndStep(ITestResult testResult) {
if (testResult.getThrowable() != null) {
logger.error(testResult.getThrowable().getMessage());
// when error occurs, exception raised is not added to the step if this error is outside of a PageObject
// we add it there as an exception always terminates the test (except for soft assert, but this case is handled in SoftAssertion.aj)
TestStep lastStep = TestStepManager.getCurrentRootTestStep();
if (lastStep == null) {
// when steps are automatic, they are closed (lastStep is null) once method is finished
try {
lastStep = Iterables.getLast(SeleniumTestsContextManager.getThreadContext().getTestStepManager().getTestSteps());
} catch (NoSuchElementException e) {
// if last step does not exist, do not crash
}
}
if (lastStep != null) {
lastStep.setFailed(true);
lastStep.setActionException(testResult.getThrowable());
}
Info lastStateInfo = TestNGResultUtils.getTestInfo(testResult).get(TestStepManager.LAST_STATE_NAME);
((MultipleInfo) lastStateInfo).addInfo(new LogInfo(testResult.getThrowable().getMessage()));
}
}
Aggregations