Details
-
Type: Bug
-
Status: Resolved
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 3.2
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
Consider WebDriver situations, where the order below is nearly always going to be the case:
new PerStoriesWebDriverSteps(..),
new PerStoriesContextView(..),
new WebDriverScreenshotOnFailure(..)
If we change from PerStoriesWebDriverSteps to PerScenarioWebDriverSteps, then we have a problem. PerScenarioWebDriverSteps could conceivable drop the reference to WebDriver after closing it, and cause WebDriverScreenshotOnFailure to fail when it's needing to leap into action.
The reproduction involved making steps fail, and making the PerStoriesWebDriverSteps to PerScenarioWebDriverSteps change.
Activity
Paul Hammant
made changes -
Field | Original Value | New Value |
---|---|---|
Status | Open [ 1 ] | Resolved [ 5 ] |
Assignee | Paul Hammant [ paul ] | |
Fix Version/s | 3.2 [ 16757 ] | |
Resolution | Fixed [ 1 ] |
The following will do it. There's no broken unit-tests for this
I can confirm that the purposefully broken Etsy (Cart can't find selector) with a change to PerScenarioWebDriver works as would be hoped for.
.......................
— a/jbehave-core/src/main/java/org/jbehave/core/steps/MarkUnmatchedStepsAsPending.java
+++ b/jbehave-core/src/main/java/org/jbehave/core/steps/MarkUnmatchedStepsAsPending.java
@@ -44,15 +44,17 @@ public class MarkUnmatchedStepsAsPending implements StepCollector {
}
public List<Step> collectBeforeOrAfterScenarioSteps(List<CandidateSteps> candidateSteps, Stage stage, boolean failureO
+ List<Step> beforeSteps = new ArrayList<Step>();
+ List<Step> afterSteps = new ArrayList<Step>();
for (CandidateSteps candidates : candidateSteps) { List<BeforeOrAfterStep> beforeOrAfterScenarioSteps = candidates.listBeforeOrAfterScenario(); if (stage == Stage.BEFORE) - steps.addAll(createSteps(beforeOrAfterScenarioSteps, stage)); + beforeSteps.addAll(createSteps(beforeOrAfterScenarioSteps, stage)); else - steps.addAll(createStepsUponOutcome(beforeOrAfterScenarioSteps, stage, failureOccured)); + afterSteps.addAll(0, createStepsUponOutcome(beforeOrAfterScenarioSteps, stage, failureOccured)); }
-
+ List<Step> steps = new ArrayList<Step>(beforeSteps);
+ steps.addAll(afterSteps);
return steps;
}