Search in sources :

Example 36 with Step

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

the class JavaStepDefinitionTest method throws_ambiguous_when_two_matches_are_found.

@Test
public void throws_ambiguous_when_two_matches_are_found() throws Throwable {
    backend.addStepDefinition(THREE_DISABLED_MICE.getAnnotation(Given.class), THREE_DISABLED_MICE);
    backend.addStepDefinition(THREE_BLIND_ANIMALS.getAnnotation(Given.class), THREE_BLIND_ANIMALS);
    Reporter reporter = mock(Reporter.class);
    runtime.buildBackendWorlds(reporter, Collections.<Tag>emptySet(), mock(Scenario.class));
    Tag tag = new Tag("@foo", 0);
    runtime.runBeforeHooks(reporter, asSet(tag));
    runtime.runStep("some.feature", new Step(NO_COMMENTS, "Given ", "three blind mice", 1, null, null), reporter, ENGLISH);
    ArgumentCaptor<Result> result = ArgumentCaptor.forClass(Result.class);
    verify(reporter).result(result.capture());
    assertEquals(AmbiguousStepDefinitionsException.class, result.getValue().getError().getClass());
}
Also used : Given(cucumber.api.java.en.Given) Reporter(gherkin.formatter.Reporter) Tag(gherkin.formatter.model.Tag) Step(gherkin.formatter.model.Step) Scenario(gherkin.formatter.model.Scenario) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 37 with Step

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

the class FromDataTableTest method runStepDef.

private StepDefs runStepDef(Method method, List<DataTableRow> rows) throws Throwable {
    StepDefs stepDefs = new StepDefs();
    StepDefinition stepDefinition = new StubStepDefinition(stepDefs, method, "some pattern");
    Step stepWithRows = new Step(NO_COMMENTS, "Given ", "something", 10, rows, null);
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(NO_ARGS, stepDefinition, "some.feature", stepWithRows, new LocalizedXStreams(classLoader));
    stepDefinitionMatch.runStep(new I18n("en"));
    return stepDefs;
}
Also used : StubStepDefinition(cucumber.runtime.StubStepDefinition) StepDefinition(cucumber.runtime.StepDefinition) StubStepDefinition(cucumber.runtime.StubStepDefinition) Step(gherkin.formatter.model.Step) StepDefinitionMatch(cucumber.runtime.StepDefinitionMatch) LocalizedXStreams(cucumber.runtime.xstream.LocalizedXStreams) I18n(gherkin.I18n)

Example 38 with Step

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

the class CucumberScenarioOutlineTest method does_not_allow_the_step_to_be_empty_after_replacement.

@Test(expected = CucumberException.class)
public void does_not_allow_the_step_to_be_empty_after_replacement() {
    Step outlineStep = new Step(C, null, "<step>", 0, null, null);
    CucumberScenarioOutline.createExampleStep(outlineStep, new ExamplesTableRow(C, asList("step"), 1, ""), new ExamplesTableRow(C, asList(""), 1, ""));
}
Also used : ExamplesTableRow(gherkin.formatter.model.ExamplesTableRow) Step(gherkin.formatter.model.Step) Test(org.junit.Test)

Example 39 with Step

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

the class JUnitFormatterTest method step.

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

Example 40 with Step

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

the class UndefinedStepsTrackerTest method has_undefined_steps.

@Test
public void has_undefined_steps() {
    UndefinedStepsTracker undefinedStepsTracker = new UndefinedStepsTracker();
    undefinedStepsTracker.addUndefinedStep(new Step(null, "Given ", "A", 1, null, null), ENGLISH);
    assertTrue(undefinedStepsTracker.hasUndefinedSteps());
}
Also used : Step(gherkin.formatter.model.Step) 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