0
Scenario A:
Step A - PENDING
Step B - PENDING

Scenario B:
Step C - Implemented
Step D - Implemented

When running the story, steps C and D are set as NOT PERFORMED. How do I get those to run even with scenario A failing due to pending steps?

I've tried setting a PendingStepStrategy to PassingUponPendingStep (and FailingUponPendingStep) but it doesn't make a difference.

edwardmlyte
  • 15,937
  • 23
  • 58
  • 83

2 Answers2

9

JBehave can be configured to keep track of state in between Scenarios. I believe the reason for this is to account for when you want to have scenarios that relate to one another.

If you check what configuration your using, then you should be able to see if you have a certain parameter on the StoryControls set.

For example

Configuration configuration = new MostUsefulConfiguration()
    .useStoryControls(new StoryControls().doResetStateBeforeScenario(false))
...

If you have the above setting, it will not perform the other scenarios as the failure state is retained

You can use JBehaves MostUsefulConfiguration class within your configuration without extra configuration, as the doResetStateBeforeScenario is set to true by default.

Lea Farmer
  • 106
  • 1
  • 4
  • Ah that's the ticket. Cheers. – edwardmlyte Dec 19 '12 at 14:08
  • just to add on, for anyone using Serenity with JBehave and Maven Fail-safe plugin, if you have a workflow requiring that their succeeding JBehave scenarios to be skipped upon failure: you can add combine Lea's answer to do so: `SerenityStories.configuration().storyControls().doSkipScenariosAfterFailure(true);` `SerenityStories.configuration().storyControls().doResetStateBeforeScenario(false);`. Many thanks for the answer, Lea! – Seng Cheong Mar 11 '20 at 15:11
0

Those steps should run anyway. I think you might have an error in the line where you declare the scenario, and JBehave thinks those four steps belong to the same scenario.

The scenarios are separated by the token Scenario:, for example

Scenario: Use a pattern variant
When the item cost is 10.0
When the price is 10.0
When the cost is 10.0


Scenario: Use a aliases variant
Then the item price is 10.0
Then the item price becomes 10.0
Then the item price equals to 10.0

Even if any of the steps in the first scenario fails, the second scenario will run.

Augusto
  • 28,839
  • 5
  • 58
  • 88
  • I have that layout. First a `Story:` token followed by the story lines. Then after that for each scenario I have `Scenario:` token with the title followed by the whens and thens. The different scenarios are displayed on the HTML results page produced. So I have done that correctly. – edwardmlyte Aug 30 '12 at 09:07
  • Sorry, I've never seen JBehave do that, unless there was an error with the story. – Augusto Aug 30 '12 at 09:21
  • Ok. I'll investigate the stories and see if there is a silly error. I'l update this when I solve the problem. Thanks. – edwardmlyte Aug 30 '12 at 09:22