forked from cucumber/cucumber-jvm
/
CucumberScenario.java
44 lines (36 loc) · 1.58 KB
/
CucumberScenario.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package cucumber.runtime.model;
import cucumber.runtime.Runtime;
import gherkin.formatter.Formatter;
import gherkin.formatter.Reporter;
import gherkin.formatter.model.Row;
import gherkin.formatter.model.Scenario;
public class CucumberScenario extends CucumberTagStatement {
private final CucumberBackground cucumberBackground;
public CucumberScenario(CucumberFeature cucumberFeature, CucumberBackground cucumberBackground, Scenario scenario) {
super(cucumberFeature, scenario);
this.cucumberBackground = cucumberBackground;
}
public CucumberScenario(CucumberFeature cucumberFeature, CucumberBackground cucumberBackground, Scenario exampleScenario, Row example) {
super(cucumberFeature, exampleScenario, example);
this.cucumberBackground = cucumberBackground;
}
/**
* This method is called when Cucumber is run from the CLI, but not when run from JUnit
*/
@Override
public void run(Formatter formatter, Reporter reporter, Runtime runtime) {
runtime.buildBackendWorlds();
runtime.runBeforeHooks(reporter, tagsAndInheritedTags());
runBackground(formatter, reporter, runtime);
format(formatter);
runSteps(reporter, runtime);
runtime.runAfterHooks(reporter, tagsAndInheritedTags());
runtime.disposeBackendWorlds();
}
private void runBackground(Formatter formatter, Reporter reporter, Runtime runtime) {
if (cucumberBackground != null) {
cucumberBackground.format(formatter);
cucumberBackground.runSteps(reporter, runtime);
}
}
}