How do I make JBehave ignore failed scenarios?

2019-06-13 15:54发布

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.

标签: jbehave
2条回答
对你真心纯属浪费
2楼-- · 2019-06-13 16:03

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.

查看更多
唯我独甜
3楼-- · 2019-06-13 16:06

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.

查看更多
登录 后发表回答