From e3f1cadb53dfc23e07ca4a9522923a5e1f6b1792 Mon Sep 17 00:00:00 2001 From: John Ferguson Smart Date: Mon, 10 Jul 2023 09:28:43 +0100 Subject: [PATCH] Revert "Fix #3141 #2920 - Make Junit recognise and report assertion failures (#3158)" This reverts commit c32b68ecf5f63793b709fc436cb1268a95d85bae. --- .../src/main/java/net/serenitybdd/core/Serenity.java | 4 ---- .../net/thucydides/core/steps/StepInterceptor.java | 6 +++--- .../displayName/JUnit5DisplayNameExample.java | 8 +------- .../integration/displayName/steps/TestExample.java | 10 ---------- 4 files changed, 4 insertions(+), 24 deletions(-) delete mode 100644 serenity-junit5/src/test/java/net/serenitybdd/junit5/samples/integration/displayName/steps/TestExample.java diff --git a/serenity-core/src/main/java/net/serenitybdd/core/Serenity.java b/serenity-core/src/main/java/net/serenitybdd/core/Serenity.java index 4c23c50d5..b03916025 100644 --- a/serenity-core/src/main/java/net/serenitybdd/core/Serenity.java +++ b/serenity-core/src/main/java/net/serenitybdd/core/Serenity.java @@ -329,10 +329,6 @@ public static void throwExceptionsImmediately() { throwExceptionsImmediately = true; } - public static boolean shouldThrowExceptionsImmediately() { - return throwExceptionsImmediately = true; - } - public static boolean shouldThrowErrorsImmediately() { return throwExceptionsImmediately; } diff --git a/serenity-core/src/main/java/net/thucydides/core/steps/StepInterceptor.java b/serenity-core/src/main/java/net/thucydides/core/steps/StepInterceptor.java index 4dc8b1e36..9461ce689 100644 --- a/serenity-core/src/main/java/net/thucydides/core/steps/StepInterceptor.java +++ b/serenity-core/src/main/java/net/thucydides/core/steps/StepInterceptor.java @@ -606,7 +606,7 @@ private void notifyOfStepFailure(final Object object, final Method method, final else { StepEventBus.getParallelEventBus().stepFailed(failure); } - if (shouldThrowExceptionsImmediately()) { + if (shouldThrowExceptionImmediately()) { finishAnyCucumberSteps(); throw cause; } @@ -623,8 +623,8 @@ private void finishAnyCucumberSteps() { } } - private boolean shouldThrowExceptionsImmediately() { - return Serenity.shouldThrowExceptionsImmediately(); + private boolean shouldThrowExceptionImmediately() { + return Serenity.shouldThrowErrorsImmediately(); } private void notifyStepStarted(final Object object, final Method method, final Object[] args) { diff --git a/serenity-junit5/src/test/java/net/serenitybdd/junit5/samples/integration/displayName/JUnit5DisplayNameExample.java b/serenity-junit5/src/test/java/net/serenitybdd/junit5/samples/integration/displayName/JUnit5DisplayNameExample.java index a5bf46dcb..2616550ac 100644 --- a/serenity-junit5/src/test/java/net/serenitybdd/junit5/samples/integration/displayName/JUnit5DisplayNameExample.java +++ b/serenity-junit5/src/test/java/net/serenitybdd/junit5/samples/integration/displayName/JUnit5DisplayNameExample.java @@ -1,8 +1,7 @@ package net.serenitybdd.junit5.samples.integration.displayName; import net.serenitybdd.junit5.SerenityJUnit5Extension; -import net.serenitybdd.junit5.samples.integration.displayName.steps.TestExample; -import net.thucydides.core.annotations.Steps; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; @@ -13,16 +12,11 @@ @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) public class JUnit5DisplayNameExample { - @Steps - TestExample testExample; - - @Test void test_spaces_ok() { } @Test void test_spaces_fail() { - testExample.test_spaces_fail(); } } \ No newline at end of file diff --git a/serenity-junit5/src/test/java/net/serenitybdd/junit5/samples/integration/displayName/steps/TestExample.java b/serenity-junit5/src/test/java/net/serenitybdd/junit5/samples/integration/displayName/steps/TestExample.java deleted file mode 100644 index 8a2e0e918..000000000 --- a/serenity-junit5/src/test/java/net/serenitybdd/junit5/samples/integration/displayName/steps/TestExample.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.serenitybdd.junit5.samples.integration.displayName.steps; - -import net.thucydides.core.steps.ScenarioSteps; -import org.junit.Assert; - -public class TestExample extends ScenarioSteps { - public void test_spaces_fail() { - Assert.assertTrue(false); - } -} \ No newline at end of file