问题
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.
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/12192539/how-do-i-make-jbehave-ignore-failed-scenarios