Search in sources :

Example 1 with LogInfo

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()));
    }
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) LogInfo(com.seleniumtests.reporter.info.LogInfo) MultipleInfo(com.seleniumtests.reporter.info.MultipleInfo) Info(com.seleniumtests.reporter.info.Info) MultipleInfo(com.seleniumtests.reporter.info.MultipleInfo) LogInfo(com.seleniumtests.reporter.info.LogInfo)

Aggregations

Info (com.seleniumtests.reporter.info.Info)1 LogInfo (com.seleniumtests.reporter.info.LogInfo)1 MultipleInfo (com.seleniumtests.reporter.info.MultipleInfo)1 TestStep (com.seleniumtests.reporter.logger.TestStep)1