Search in sources :

Example 1 with CucumberScenario

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;
}
Also used : Runner(org.junit.runner.Runner) InitializationError(org.junit.runners.model.InitializationError) ArrayList(java.util.ArrayList) CucumberScenario(cucumber.runtime.model.CucumberScenario)

Example 2 with CucumberScenario

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);
        }
    }
}
Also used : CucumberScenarioOutline(cucumber.runtime.model.CucumberScenarioOutline) InitializationError(org.junit.runners.model.InitializationError) CucumberScenario(cucumber.runtime.model.CucumberScenario) CucumberTagStatement(cucumber.runtime.model.CucumberTagStatement) CucumberException(cucumber.runtime.CucumberException) ParentRunner(org.junit.runners.ParentRunner)

Example 3 with CucumberScenario

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();
}
Also used : InOrder(org.mockito.InOrder) Formatter(gherkin.formatter.Formatter) Reporter(gherkin.formatter.Reporter) CucumberScenario(cucumber.runtime.model.CucumberScenario) CucumberFeature(cucumber.runtime.model.CucumberFeature) Feature(gherkin.formatter.model.Feature) CucumberFeature(cucumber.runtime.model.CucumberFeature) ClasspathResourceLoader(cucumber.runtime.io.ClasspathResourceLoader) Tag(gherkin.formatter.model.Tag) Test(org.junit.Test)

Aggregations

CucumberScenario (cucumber.runtime.model.CucumberScenario)3 InitializationError (org.junit.runners.model.InitializationError)2 CucumberException (cucumber.runtime.CucumberException)1 ClasspathResourceLoader (cucumber.runtime.io.ClasspathResourceLoader)1 CucumberFeature (cucumber.runtime.model.CucumberFeature)1 CucumberScenarioOutline (cucumber.runtime.model.CucumberScenarioOutline)1 CucumberTagStatement (cucumber.runtime.model.CucumberTagStatement)1 Formatter (gherkin.formatter.Formatter)1 Reporter (gherkin.formatter.Reporter)1 Feature (gherkin.formatter.model.Feature)1 Tag (gherkin.formatter.model.Tag)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Runner (org.junit.runner.Runner)1 ParentRunner (org.junit.runners.ParentRunner)1 InOrder (org.mockito.InOrder)1