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 b03916025..4c23c50d5 100644 --- a/serenity-core/src/main/java/net/serenitybdd/core/Serenity.java +++ b/serenity-core/src/main/java/net/serenitybdd/core/Serenity.java @@ -329,6 +329,10 @@ 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 9461ce689..4dc8b1e36 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 (shouldThrowExceptionImmediately()) { + if (shouldThrowExceptionsImmediately()) { finishAnyCucumberSteps(); throw cause; } @@ -623,8 +623,8 @@ private void finishAnyCucumberSteps() { } } - private boolean shouldThrowExceptionImmediately() { - return Serenity.shouldThrowErrorsImmediately(); + private boolean shouldThrowExceptionsImmediately() { + return Serenity.shouldThrowExceptionsImmediately(); } 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 2616550ac..a5bf46dcb 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,7 +1,8 @@ package net.serenitybdd.junit5.samples.integration.displayName; import net.serenitybdd.junit5.SerenityJUnit5Extension; -import org.junit.jupiter.api.DisplayName; +import net.serenitybdd.junit5.samples.integration.displayName.steps.TestExample; +import net.thucydides.core.annotations.Steps; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; @@ -12,11 +13,16 @@ @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 new file mode 100644 index 000000000..8a2e0e918 --- /dev/null +++ b/serenity-junit5/src/test/java/net/serenitybdd/junit5/samples/integration/displayName/steps/TestExample.java @@ -0,0 +1,10 @@ +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