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 c8835c723..38b457ac7 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 @@ -492,7 +492,7 @@ private Object runTestStep(final Object obj, final Method method, } private void logStepFailure(Object object, Method method, Object[] args, Throwable assertionError) throws Throwable { - if (StepEventBus.getEventBus().aStepInTheCurrentTestHasFailed()) { + if (StepEventBus.getEventBus().aStepInTheCurrentTestHasFailed() && !StepEventBus.getEventBus().softAssertsActive()) { return; } notifyOfStepFailure(object, method, args, assertionError); diff --git a/serenity-core/src/test/java/net/thucydides/core/steps/WhenRecordingStepExecutionResults.java b/serenity-core/src/test/java/net/thucydides/core/steps/WhenRecordingStepExecutionResults.java index 4cc46be0c..0809d0e0b 100644 --- a/serenity-core/src/test/java/net/thucydides/core/steps/WhenRecordingStepExecutionResults.java +++ b/serenity-core/src/test/java/net/thucydides/core/steps/WhenRecordingStepExecutionResults.java @@ -845,6 +845,31 @@ public void a_failing_step_should_record_the_failure_details_with_the_step() { assertThat(testOutcome.getTestSteps().get(1).getErrorMessage(), containsString("Step failed")); } + @Test + public void a_failing_step_should_not_prevent_collecting_next_steps_result_if_soft_asserts_enabled() throws Exception { + + StepEventBus.getParallelEventBus().testSuiteStarted(MyTestCase.class); + StepEventBus.getParallelEventBus().testStarted("app_should_work"); + StepEventBus.getParallelEventBus().enableSoftAsserts(); + + FlatScenarioSteps steps = stepFactory.getSharedStepLibraryFor(FlatScenarioSteps.class); + steps.step_one(); + steps.failingWithExceptionStep(); + steps.step_two(); + steps.failingWithExceptionStep(); + steps.step_three(); + StepEventBus.getParallelEventBus().testFinished(testOutcome); + + List results = stepListener.getTestOutcomes(); + TestOutcome testOutcome = results.get(0); + + assertThat(testOutcome.getTestSteps().size(), equalTo(5)); + TestResult[] expectedResults = {TestResult.SUCCESS, TestResult.ERROR, TestResult.SUCCESS, TestResult.ERROR, TestResult.SUCCESS}; + for (int i = 0; i < testOutcome.getTestSteps().size(); i++) { + assertThat(testOutcome.getTestSteps().get(i).getResult(), is(expectedResults[i])); + } + } + @Test public void ignored_tests_should_be_reported() { diff --git a/serenity-core/src/test/java/net/thucydides/core/steps/samples/FlatScenarioSteps.java b/serenity-core/src/test/java/net/thucydides/core/steps/samples/FlatScenarioSteps.java index a97a2ce92..0943d90a9 100644 --- a/serenity-core/src/test/java/net/thucydides/core/steps/samples/FlatScenarioSteps.java +++ b/serenity-core/src/test/java/net/thucydides/core/steps/samples/FlatScenarioSteps.java @@ -67,6 +67,11 @@ public void failingStep() { throw new AssertionError("Step failed"); } + @Step + public void failingWithExceptionStep() throws Exception { + throw new Exception("Step failed due to exception"); + } + @Ignore @Step public void ignoredStep() {}