Skip to content

Commit

Permalink
refactor based on discussion #1436
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Jan 17, 2021
1 parent aeea188 commit 7095b6f
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.Semaphore;
import java.util.concurrent.locks.ReentrantLock;

/**
*
Expand Down Expand Up @@ -88,11 +87,13 @@ public ScenarioRuntime(FeatureRuntime featureRuntime, Scenario scenario, Scenari
logger.setAppender(logAppender);
actions = new ScenarioActions(engine);
this.scenario = scenario;
magicVariables = initMagicVariables(background); // depends on scenario
this.background = background; // used only to check which steps remain
magicVariables = initMagicVariables();
result = new ScenarioResult(scenario);
if (background != null) {
result.addStepResults(background.result.getStepResults());
Map<String, Variable> detached = background.engine.detachVariables();
engine.vars.putAll(detached);
}
dryRun = featureRuntime.suite.dryRun;
tags = scenario.getTagsEffective();
Expand Down Expand Up @@ -243,14 +244,8 @@ protected void logError(String message) {
logger.error("{}", message);
}

private Map<String, Object> initMagicVariables(ScenarioRuntime background) {
private Map<String, Object> initMagicVariables() {
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 7095b6f

Please sign in to comment.