From 8006229382b278ca97ad3aaf8dfd2a5be4ad29ff Mon Sep 17 00:00:00 2001 From: Liviu Carausu Date: Sun, 22 Dec 2024 19:40:21 +0100 Subject: [PATCH 1/3] #possible fix for https://github.com/serenity-bdd/serenity-core/issues/3546 --- .../io/cucumber/core/plugin/ScenarioContextParallel.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 177176e85..e2dfa0cc5 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; @@ -334,6 +336,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 { From a9c4c65faab98a55836fa8be878b83709b1f9c95 Mon Sep 17 00:00:00 2001 From: Liviu Carausu Date: Sun, 22 Dec 2024 19:42:29 +0100 Subject: [PATCH 2/3] improve logging --- .../cucumber/events/StepFinishedWithResultEvent.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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..a035b51e8 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,7 @@ private String currentStepTitle() { ? getStepEventBus().getCurrentStep().get().getDescription() : ""; } + public String toString() { + return("EventBusEvent STEP_FINISHED_WITH_RESULT with result " + result); + } } From 87918b75ac88ebb4e85a4a2ddb60840fac5da1aa Mon Sep 17 00:00:00 2001 From: Liviu Carausu Date: Sun, 22 Dec 2024 19:45:41 +0100 Subject: [PATCH 3/3] expose result --- .../cucumber/events/StepFinishedWithResultEvent.java | 4 ++++ 1 file changed, 4 insertions(+) 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 a035b51e8..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 @@ -141,6 +141,10 @@ private String currentStepTitle() { ? getStepEventBus().getCurrentStep().get().getDescription() : ""; } + public Result getResult() { + return result; + } + public String toString() { return("EventBusEvent STEP_FINISHED_WITH_RESULT with result " + result); }