use of cucumber.runtime.model.CucumberScenario in project cucumber-jvm by cucumber.
the class ExamplesRunner method buildRunners.
private static List<Runner> buildRunners(Runtime runtime, CucumberExamples cucumberExamples, JUnitReporter jUnitReporter) {
List<Runner> runners = new ArrayList<Runner>();
List<CucumberScenario> exampleScenarios = cucumberExamples.createExampleScenarios();
for (CucumberScenario scenario : exampleScenarios) {
try {
ExecutionUnitRunner exampleScenarioRunner = new ExecutionUnitRunner(runtime, scenario, jUnitReporter);
runners.add(exampleScenarioRunner);
} catch (InitializationError initializationError) {
initializationError.printStackTrace();
}
}
return runners;
}
use of cucumber.runtime.model.CucumberScenario in project cucumber-jvm by cucumber.
the class FeatureRunner method buildFeatureElementRunners.
private void buildFeatureElementRunners() {
for (CucumberTagStatement cucumberTagStatement : cucumberFeature.getFeatureElements()) {
try {
ParentRunner featureElementRunner;
if (cucumberTagStatement instanceof CucumberScenario) {
featureElementRunner = new ExecutionUnitRunner(runtime, (CucumberScenario) cucumberTagStatement, jUnitReporter);
} else {
featureElementRunner = new ScenarioOutlineRunner(runtime, (CucumberScenarioOutline) cucumberTagStatement, jUnitReporter);
}
children.add(featureElementRunner);
} catch (InitializationError e) {
throw new CucumberException("Failed to create scenario runner", e);
}
}
}
use of cucumber.runtime.model.CucumberScenario in project cucumber-jvm by cucumber.
the class HookTest method after_hooks_execute_before_objects_are_disposed.
/**
* Test for <a href="https://github.com/cucumber/cucumber-jvm/issues/23">#23</a>.
* TODO: ensure this is no longer needed with the alternate approach taken in Runtime
* TODO: this test is rather brittle, since there's lots of mocking :(
*/
@Test
public void after_hooks_execute_before_objects_are_disposed() throws Throwable {
Backend backend = mock(Backend.class);
HookDefinition hook = mock(HookDefinition.class);
when(hook.matches(anyListOf(Tag.class))).thenReturn(true);
gherkin.formatter.model.Scenario gherkinScenario = mock(gherkin.formatter.model.Scenario.class);
CucumberFeature feature = mock(CucumberFeature.class);
Feature gherkinFeature = mock(Feature.class);
when(feature.getGherkinFeature()).thenReturn(gherkinFeature);
when(gherkinFeature.getTags()).thenReturn(new ArrayList<Tag>());
CucumberScenario scenario = new CucumberScenario(feature, null, gherkinScenario);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
RuntimeOptions runtimeOptions = new RuntimeOptions("");
Runtime runtime = new Runtime(new ClasspathResourceLoader(classLoader), classLoader, asList(backend), runtimeOptions);
runtime.getGlue().addAfterHook(hook);
scenario.run(mock(Formatter.class), mock(Reporter.class), runtime);
InOrder inOrder = inOrder(hook, backend);
inOrder.verify(hook).execute(Matchers.<Scenario>any());
inOrder.verify(backend).disposeWorld();
}
Aggregations