diff --git a/serenity-cucumber/src/main/java/io/cucumber/core/plugin/ScenarioContextParallel.java b/serenity-cucumber/src/main/java/io/cucumber/core/plugin/ScenarioContextParallel.java index 3b9d01eb5..13cefff6e 100644 --- a/serenity-cucumber/src/main/java/io/cucumber/core/plugin/ScenarioContextParallel.java +++ b/serenity-cucumber/src/main/java/io/cucumber/core/plugin/ScenarioContextParallel.java @@ -1,6 +1,8 @@ package io.cucumber.core.plugin; +import io.cucumber.plugin.event.Status; +import net.serenitybdd.cucumber.events.StepFinishedWithResultEvent; import net.serenitybdd.model.exceptions.SerenityManagedException; import net.thucydides.core.steps.events.StepEventBusEvent; import io.cucumber.messages.types.Scenario; @@ -337,6 +339,12 @@ public void addHighPriorityStepEventBusEvent(String scenarioId, StepEventBusEven public void addStepEventBusEvent(StepEventBusEvent event) { if (TestSession.isSessionStarted()) { + if (event instanceof StepFinishedWithResultEvent) { + if (Status.FAILED.equals(((StepFinishedWithResultEvent) event).getResult().getStatus()) && TestSession.currentStepHasFailed()) { + LOGGER.debug("SRP:ignored event " + event + " " + Thread.currentThread() + " because current Step has already failed"); + return; + } + } TestSession.addEvent(event); event.setStepEventBus(stepEventBus); } else { diff --git a/serenity-cucumber/src/main/java/net/serenitybdd/cucumber/events/StepFinishedWithResultEvent.java b/serenity-cucumber/src/main/java/net/serenitybdd/cucumber/events/StepFinishedWithResultEvent.java index 48160bb31..9b50d853b 100644 --- a/serenity-cucumber/src/main/java/net/serenitybdd/cucumber/events/StepFinishedWithResultEvent.java +++ b/serenity-cucumber/src/main/java/net/serenitybdd/cucumber/events/StepFinishedWithResultEvent.java @@ -59,7 +59,7 @@ public void play() { private void failed(String stepTitle, Throwable cause, List screenshots) { - if (!errorOrFailureRecordedForStep(stepTitle, cause)) { + if (!errorOrFailureRecordedForStep(stepTitle, cause)) { if (!isEmpty(stepTitle)) { getStepEventBus().updateCurrentStepTitle(stepTitle); } @@ -141,4 +141,11 @@ private String currentStepTitle() { ? getStepEventBus().getCurrentStep().get().getDescription() : ""; } + public Result getResult() { + return result; + } + + public String toString() { + return("EventBusEvent STEP_FINISHED_WITH_RESULT with result " + result); + } }