Search in sources :

Example 6 with Step

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

the class CucumberScenarioOutlineTest method allows_data_table_entries_to_be_empty_after_replacement.

@Test
public void allows_data_table_entries_to_be_empty_after_replacement() {
    List<DataTableRow> rows = asList(new DataTableRow(C, asList("<entry>"), 1));
    Step outlineStep = new Step(C, null, "Some step", 0, rows, null);
    Step exampleStep = CucumberScenarioOutline.createExampleStep(outlineStep, new ExamplesTableRow(C, asList("entry"), 1, ""), new ExamplesTableRow(C, asList(""), 1, ""));
    assertEquals(asList(""), exampleStep.getRows().get(0).getCells());
}
Also used : ExamplesTableRow(gherkin.formatter.model.ExamplesTableRow) Step(gherkin.formatter.model.Step) DataTableRow(gherkin.formatter.model.DataTableRow) Test(org.junit.Test)

Example 7 with Step

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

the class JavaStepDefinitionTest method does_not_throw_ambiguous_when_nothing_is_ambiguous.

@Test
public void does_not_throw_ambiguous_when_nothing_is_ambiguous() throws Throwable {
    backend.addStepDefinition(THREE_DISABLED_MICE.getAnnotation(Given.class), THREE_DISABLED_MICE);
    Reporter reporter = new Reporter() {

        @Override
        public void before(Match match, Result result) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void result(Result result) {
            if (result.getError() != null) {
                throw new RuntimeException(result.getError());
            }
        }

        @Override
        public void after(Match match, Result result) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void match(Match match) {
        }

        @Override
        public void embedding(String mimeType, byte[] data) {
        }

        @Override
        public void write(String text) {
        }
    };
    runtime.buildBackendWorlds(reporter, Collections.<Tag>emptySet(), mock(Scenario.class));
    Tag tag = new Tag("@foo", 0);
    Set<Tag> tags = asSet(tag);
    runtime.runBeforeHooks(reporter, tags);
    Step step = new Step(NO_COMMENTS, "Given ", "three blind mice", 1, null, null);
    runtime.runStep("some.feature", step, reporter, ENGLISH);
    assertTrue(defs.foo);
    assertFalse(defs.bar);
}
Also used : Given(cucumber.api.java.en.Given) Reporter(gherkin.formatter.Reporter) Tag(gherkin.formatter.model.Tag) Step(gherkin.formatter.model.Step) Match(gherkin.formatter.model.Match) Result(gherkin.formatter.model.Result) Scenario(gherkin.formatter.model.Scenario) Test(org.junit.Test)

Example 8 with Step

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

the class ExecutionUnitRunnerTest method shouldAssignUnequalDescriptionsToDifferentOccurrencesOfSameStepInAScenario.

@Test
public void shouldAssignUnequalDescriptionsToDifferentOccurrencesOfSameStepInAScenario() throws Exception {
    List<CucumberFeature> features = CucumberFeature.load(new ClasspathResourceLoader(this.getClass().getClassLoader()), asList("cucumber/runtime/junit/fb.feature"), Collections.emptyList());
    ExecutionUnitRunner runner = new ExecutionUnitRunner(null, (CucumberScenario) features.get(0).getFeatureElements().get(0), createStandardJUnitReporter());
    // fish out the two occurrences of the same step and check whether we really got them
    Step stepOccurrence1 = runner.getChildren().get(0);
    Step stepOccurrence2 = runner.getChildren().get(2);
    assertEquals(stepOccurrence1.getName(), stepOccurrence2.getName());
    // then check that the descriptions are unequal
    Description runnerDescription = runner.getDescription();
    Description stepDescription1 = runnerDescription.getChildren().get(0);
    Description stepDescription2 = runnerDescription.getChildren().get(2);
    assertFalse("Descriptions must not be equal.", stepDescription1.equals(stepDescription2));
}
Also used : Description(org.junit.runner.Description) CucumberFeature(cucumber.runtime.model.CucumberFeature) ClasspathResourceLoader(cucumber.runtime.io.ClasspathResourceLoader) Step(gherkin.formatter.model.Step) Test(org.junit.Test)

Example 9 with Step

use of gherkin.formatter.model.Step 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 10 with Step

use of gherkin.formatter.model.Step 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

Step (gherkin.formatter.model.Step)50 Test (org.junit.Test)34 LocalizedXStreams (cucumber.runtime.xstream.LocalizedXStreams)9 Argument (gherkin.formatter.Argument)9 ExamplesTableRow (gherkin.formatter.model.ExamplesTableRow)7 Scenario (gherkin.formatter.model.Scenario)7 DocString (gherkin.formatter.model.DocString)6 Description (org.junit.runner.Description)6 I18n (gherkin.I18n)5 CucumberFeature (cucumber.runtime.model.CucumberFeature)4 DataTableRow (gherkin.formatter.model.DataTableRow)4 Match (gherkin.formatter.model.Match)4 CucumberException (cucumber.runtime.CucumberException)3 SnippetGenerator (cucumber.runtime.snippets.SnippetGenerator)3 Tag (gherkin.formatter.model.Tag)3 GherkinStep (org.jetbrains.plugins.cucumber.psi.GherkinStep)3 RunNotifier (org.junit.runner.notification.RunNotifier)3 Given (cucumber.api.java.en.Given)2 StepDefinition (cucumber.runtime.StepDefinition)2 StepDefinitionMatch (cucumber.runtime.StepDefinitionMatch)2