Skip to content

Commit

Permalink
attempt solution for problem ref #1436
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Jan 16, 2021
1 parent 1696571 commit aeea188
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,10 @@ public ScenarioRuntime(FeatureRuntime featureRuntime, Scenario scenario, Scenari
logger.setAppender(logAppender);
actions = new ScenarioActions(engine);
this.scenario = scenario;
magicVariables = initMagicVariables(); // depends on scenario
magicVariables = initMagicVariables(background); // depends on scenario
this.background = background; // used only to check which steps remain
result = new ScenarioResult(scenario);
if (background != null) {
// detaching is as good as cloning
// the detach is needed as the js-engine will be different
Map<String, Variable> detached = background.engine.detachVariables();
detached.forEach((k, v) -> magicVariables.put(k, v.getValue()));
result.addStepResults(background.result.getStepResults());
}
dryRun = featureRuntime.suite.dryRun;
Expand Down Expand Up @@ -247,8 +243,14 @@ protected void logError(String message) {
logger.error("{}", message);
}

private Map<String, Object> initMagicVariables() {
private Map<String, Object> initMagicVariables(ScenarioRuntime background) {
Map<String, Object> map = new HashMap();
if (background != null) {
// detaching is as good as cloning
// the detach is needed as the js-engine will be different
Map<String, Variable> detached = background.engine.detachVariables();
detached.forEach((k, v) -> map.put(k, v.getValue()));
}
if (caller.isNone()) { // if feature called via java api
if (caller.arg != null && caller.arg.isMap()) {
map.putAll(caller.arg.getValue());
Expand Down

0 comments on commit aeea188

Please sign in to comment.