Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand All @@ -64,6 +65,8 @@ class GherkinCallback implements Formatter, Reporter {

private CucumberTestResult testResult;

private List<BeforeAfterResult> backgroundBeforeAfterResults = null;


GherkinCallback(CucumberTestResult testResult) {
this.testResult = testResult;
Expand Down Expand Up @@ -113,6 +116,7 @@ public void background(Background background) {
throw new CucumberModelException("Background: {" + background.getName() + "} received before previous background: {" + currentBackground.getName()+ "} handled");
}
currentBackground = new BackgroundResult(background);
backgroundBeforeAfterResults = new ArrayList<BeforeAfterResult>();
}


Expand All @@ -130,6 +134,12 @@ public void scenario(Scenario scenario) {
currentScenarioResult = new ScenarioResult(scenario, currentBackground);
currentBackground = null;
currentFeatureResult.addScenarioResult(currentScenarioResult);

if (backgroundBeforeAfterResults != null) {
for (BeforeAfterResult beforeAfterResult : backgroundBeforeAfterResults) {
currentScenarioResult.addBeforeResult(beforeAfterResult);
}
}
}


Expand Down Expand Up @@ -218,7 +228,12 @@ public void before(Match match, Result result) {
LOG.log(Level.FINE, "rep result : " + result.getErrorMessage());
LOG.log(Level.FINE, "rep result : " + result.getError());
}
currentScenarioResult.addBeforeResult(new BeforeAfterResult(match, result));

if (currentScenarioResult != null) {
currentScenarioResult.addBeforeResult(new BeforeAfterResult(match, result));
} else {
backgroundBeforeAfterResults.add(new BeforeAfterResult(match, result));
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
"name": "A Calculator",
"keyword": "Background",
"line": 4,
"before":[
{
"match":{
"location":"SomeLocation"
},
"result":{
"status":"passed",
"duration":0
}
}
],
"steps": [
{
"result": {
Expand Down