4

I have allure listener which reports all selenide asserts but in case of fail only sub step is marked as failed. and It is unclear from report

Listener:

@Override
public void beforeEvent(final LogEvent event) {
    lifecycle.getCurrentTestCaseOrStep().ifPresent(parentUuid -> {
        final String uuid = UUID.randomUUID().toString();
        lifecycle.startStep(parentUuid, uuid, new StepResult().setName(event.toString()));
    });
}

@Override
public void afterEvent(final LogEvent event) {
    lifecycle.getCurrentTestCaseOrStep().ifPresent(parentUuid -> {
        switch (event.getStatus()) {
            case PASS:
                lifecycle.updateStep(step -> step.setStatus(Status.PASSED));
                break;
            case FAIL:
                if (saveScreenshots) {
                    getScreenshotBytes()
                            .ifPresent(bytes -> lifecycle.addAttachment("Screenshot", "image/png", "png", bytes));
                }
                if (savePageHtml) {
                    getPageSourceBytes()
                            .ifPresent(bytes -> lifecycle.addAttachment("Page source", "text/html", "html", bytes));
                }
                if (!logTypesToSave.isEmpty()) {
                    logTypesToSave
                        .forEach((logType, level) -> {
                            final byte[] content = getBrowserLogs(logType, level).getBytes(UTF_8);
                            lifecycle.addAttachment("Logs from: " + logType, "application/json", ".txt", content);
                            });
                }
                lifecycle.updateStep(stepResult -> {
                    stepResult.setStatus(getStatus(event.getError()).orElse(Status.BROKEN));
                    stepResult.setStatusDetails(getStatusDetails(event.getError()).orElse(new StatusDetails()));
                });
                break;
            default:
                LOGGER.warn("Step finished with unsupported status {}", event.getStatus());
                break;
        }
        lifecycle.stopStep();
    });
}

}

Screenshot of report:

enter image description here As you can see parent step is marked as passed.

Anton_Selenium
  • 339
  • 7
  • 20

1 Answers1

1

resolved this issue by failing current step multiple times

Allure.getLifecycle().updateStep(stepResult -> stepResult.setStatus(Status.FAILED));
Allure.getLifecycle().stopStep();
Allure.getLifecycle().updateStep(stepResult -> stepResult.setStatus(Status.FAILED));
Allure.getLifecycle().stopStep();
Allure.getLifecycle().updateStep(stepResult -> stepResult.setStatus(Status.FAILED));
Allure.getLifecycle().stopStep();

not a good way to do the job, but it works fine for me

usefull video https://www.youtube.com/watch?v=d5gjK6hZHE4&feature=youtu.be if you can understand russian