Search in sources :

Example 1 with Scenario

use of gherkin.formatter.model.Scenario in project cucumber-jvm by cucumber.

the class CucumberScenarioOutline method createExampleScenario.

CucumberScenario createExampleScenario(ExamplesTableRow header, ExamplesTableRow example, List<Tag> examplesTags, String examplesDescription) {
    // Make sure we replace the tokens in the name of the scenario
    String exampleScenarioName = replaceTokens(new HashSet<Integer>(), header.getCells(), example.getCells(), getGherkinModel().getName());
    String exampleScenarioDescription = createExampleScenarioDescription(getGherkinModel().getDescription(), examplesDescription);
    Scenario exampleScenario = new Scenario(example.getComments(), examplesTags, getGherkinModel().getKeyword(), exampleScenarioName, exampleScenarioDescription, example.getLine(), example.getId());
    CucumberScenario cucumberScenario = new CucumberScenario(cucumberFeature, cucumberBackground, exampleScenario, example);
    for (Step step : getSteps()) {
        cucumberScenario.step(createExampleStep(step, header, example));
    }
    return cucumberScenario;
}
Also used : DocString(gherkin.formatter.model.DocString) Step(gherkin.formatter.model.Step) Scenario(gherkin.formatter.model.Scenario)

Example 2 with Scenario

use of gherkin.formatter.model.Scenario in project cucumber-jvm by cucumber.

the class HTMLFormatterTest method runFeaturesWithFormatter.

private void runFeaturesWithFormatter(URL outputDir) throws IOException {
    final HTMLFormatter f = new HTMLFormatter(outputDir);
    f.uri("some\\windows\\path\\some.feature");
    f.scenario(new Scenario(Collections.<Comment>emptyList(), Collections.<Tag>emptyList(), "Scenario", "some cukes", "", 10, "id"));
    f.embedding("image/png", "fakedata".getBytes("US-ASCII"));
    f.embedding("text/plain", "dodgy stack trace here".getBytes("US-ASCII"));
    f.done();
    f.close();
}
Also used : Comment(gherkin.formatter.model.Comment) Tag(gherkin.formatter.model.Tag) Scenario(gherkin.formatter.model.Scenario)

Example 3 with Scenario

use of gherkin.formatter.model.Scenario in project cucumber-jvm by cucumber.

the class JUnitFormatterTest method scenario.

private Scenario scenario(String keyword, String scenarioName) {
    Scenario scenario = mock(Scenario.class);
    when(scenario.getName()).thenReturn(scenarioName);
    when(scenario.getKeyword()).thenReturn(keyword);
    return scenario;
}
Also used : Scenario(gherkin.formatter.model.Scenario)

Example 4 with Scenario

use of gherkin.formatter.model.Scenario in project cucumber-jvm by cucumber.

the class JUnitReporterTest method throws_exception_when_runner_step_name_do_no_match_scenario_step_name.

@Test
public void throws_exception_when_runner_step_name_do_no_match_scenario_step_name() throws Exception {
    Step runnerStep = mockStep("Runner Step Name");
    ExecutionUnitRunner executionUnitRunner = mockExecutionUnitRunner(runnerSteps(runnerStep));
    jUnitReporter = new JUnitReporter(mock(Reporter.class), mock(Formatter.class), false, new JUnitOptions(Collections.<String>emptyList()));
    jUnitReporter.startExecutionUnit(executionUnitRunner, mock(RunNotifier.class));
    jUnitReporter.startOfScenarioLifeCycle(mock(Scenario.class));
    jUnitReporter.step(mockStep("Scenario Step Name"));
    try {
        jUnitReporter.match(mock(Match.class));
        fail("CucumberException not thrown");
    } catch (CucumberException e) {
        assertEquals("Expected step: \"Scenario Step Name\" got step: \"Runner Step Name\"", e.getMessage());
    } catch (Exception e) {
        fail("CucumberException not thrown");
    }
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Step(gherkin.formatter.model.Step) CucumberException(cucumber.runtime.CucumberException) PendingException(cucumber.api.PendingException) CucumberException(cucumber.runtime.CucumberException) Scenario(gherkin.formatter.model.Scenario) Match(gherkin.formatter.model.Match) Test(org.junit.Test)

Example 5 with Scenario

use of gherkin.formatter.model.Scenario in project cucumber-jvm by cucumber.

the class JUnitReporterTest method forward_calls_to_formatter_interface_methods.

@Test
public void forward_calls_to_formatter_interface_methods() throws Exception {
    String uri = "uri";
    Feature feature = mock(Feature.class);
    Background background = mock(Background.class);
    ScenarioOutline scenarioOutline = mock(ScenarioOutline.class);
    Examples examples = mock(Examples.class);
    Scenario scenario = mock(Scenario.class);
    Step step = mock(Step.class);
    Formatter formatter = mock(Formatter.class);
    jUnitReporter = new JUnitReporter(mock(Reporter.class), formatter, false, new JUnitOptions(Collections.<String>emptyList()));
    jUnitReporter.uri(uri);
    jUnitReporter.feature(feature);
    jUnitReporter.scenarioOutline(scenarioOutline);
    jUnitReporter.examples(examples);
    jUnitReporter.startOfScenarioLifeCycle(scenario);
    jUnitReporter.background(background);
    jUnitReporter.scenario(scenario);
    jUnitReporter.step(step);
    jUnitReporter.endOfScenarioLifeCycle(scenario);
    jUnitReporter.eof();
    jUnitReporter.done();
    jUnitReporter.close();
    verify(formatter).uri(uri);
    verify(formatter).feature(feature);
    verify(formatter).scenarioOutline(scenarioOutline);
    verify(formatter).examples(examples);
    verify(formatter).startOfScenarioLifeCycle(scenario);
    ;
    verify(formatter).background(background);
    verify(formatter).scenario(scenario);
    verify(formatter).step(step);
    verify(formatter).endOfScenarioLifeCycle(scenario);
    verify(formatter).eof();
    verify(formatter).done();
    verify(formatter).close();
}
Also used : Background(gherkin.formatter.model.Background) ScenarioOutline(gherkin.formatter.model.ScenarioOutline) Formatter(gherkin.formatter.Formatter) Step(gherkin.formatter.model.Step) Feature(gherkin.formatter.model.Feature) Examples(gherkin.formatter.model.Examples) Scenario(gherkin.formatter.model.Scenario) Test(org.junit.Test)

Aggregations

Scenario (gherkin.formatter.model.Scenario)5 Step (gherkin.formatter.model.Step)3 Test (org.junit.Test)2 PendingException (cucumber.api.PendingException)1 CucumberException (cucumber.runtime.CucumberException)1 Formatter (gherkin.formatter.Formatter)1 Background (gherkin.formatter.model.Background)1 Comment (gherkin.formatter.model.Comment)1 DocString (gherkin.formatter.model.DocString)1 Examples (gherkin.formatter.model.Examples)1 Feature (gherkin.formatter.model.Feature)1 Match (gherkin.formatter.model.Match)1 ScenarioOutline (gherkin.formatter.model.ScenarioOutline)1 Tag (gherkin.formatter.model.Tag)1 RunNotifier (org.junit.runner.notification.RunNotifier)1