【发布时间】:2020-05-07 06:49:39
【问题描述】:
我有一个 allure 监听器,它报告所有硒断言,但在失败的情况下,只有子步骤被标记为失败。并且从报告中不清楚
听众:
@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();
});
}
}
报告截图:
【问题讨论】:
标签: java selenium webdriver allure selenide