Search in sources :

Example 11 with Step

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

the class StepDefinitionMatchTest method can_have_doc_string_as_last_argument_among_many.

@Test
public void can_have_doc_string_as_last_argument_among_many() throws Throwable {
    StepDefinition stepDefinition = mock(StepDefinition.class);
    when(stepDefinition.getParameterCount()).thenReturn(2);
    when(stepDefinition.getParameterType(0, String.class)).thenReturn(new ParameterInfo(Integer.TYPE, null, null, null));
    when(stepDefinition.getParameterType(1, String.class)).thenReturn(new ParameterInfo(String.class, null, null, null));
    Step stepWithDocString = mock(Step.class);
    DocString docString = new DocString("test", "HELLO", 999);
    when(stepWithDocString.getDocString()).thenReturn(docString);
    when(stepWithDocString.getRows()).thenReturn(null);
    StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(Arrays.asList(new Argument(0, "5")), stepDefinition, "some.feature", stepWithDocString, new LocalizedXStreams(classLoader));
    stepDefinitionMatch.runStep(ENGLISH);
    verify(stepDefinition).execute(ENGLISH, new Object[] { 5, "HELLO" });
}
Also used : Argument(gherkin.formatter.Argument) DocString(gherkin.formatter.model.DocString) DocString(gherkin.formatter.model.DocString) Step(gherkin.formatter.model.Step) LocalizedXStreams(cucumber.runtime.xstream.LocalizedXStreams) Test(org.junit.Test)

Example 12 with Step

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

the class StepDefinitionMatchTest method converts_doc_string_with_explicit_converter.

@Test
public void converts_doc_string_with_explicit_converter() throws Throwable {
    StepDefinition stepDefinition = mock(StepDefinition.class);
    when(stepDefinition.getParameterCount()).thenReturn(1);
    when(stepDefinition.getParameterType(0, String.class)).thenReturn(new ParameterInfo(Thing.class, null, null, null));
    Step stepWithDocString = mock(Step.class);
    DocString docString = new DocString("test", "the thing", 999);
    when(stepWithDocString.getDocString()).thenReturn(docString);
    when(stepWithDocString.getRows()).thenReturn(null);
    StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(new ArrayList<Argument>(), stepDefinition, "some.feature", stepWithDocString, new LocalizedXStreams(classLoader));
    stepDefinitionMatch.runStep(ENGLISH);
    verify(stepDefinition).execute(ENGLISH, new Object[] { new Thing("the thing") });
}
Also used : Argument(gherkin.formatter.Argument) DocString(gherkin.formatter.model.DocString) Step(gherkin.formatter.model.Step) LocalizedXStreams(cucumber.runtime.xstream.LocalizedXStreams) Test(org.junit.Test)

Example 13 with Step

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

the class StepDefinitionMatchTest method can_have_doc_string_as_only_argument.

@Test
public void can_have_doc_string_as_only_argument() throws Throwable {
    StepDefinition stepDefinition = mock(StepDefinition.class);
    when(stepDefinition.getParameterCount()).thenReturn(1);
    when(stepDefinition.getParameterType(0, String.class)).thenReturn(new ParameterInfo(String.class, null, null, null));
    Step stepWithDocString = mock(Step.class);
    DocString docString = new DocString("text/plain", "HELLO", 999);
    when(stepWithDocString.getDocString()).thenReturn(docString);
    when(stepWithDocString.getRows()).thenReturn(null);
    StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(new ArrayList<Argument>(), stepDefinition, "some.feature", stepWithDocString, new LocalizedXStreams(classLoader));
    stepDefinitionMatch.runStep(ENGLISH);
    verify(stepDefinition).execute(ENGLISH, new Object[] { "HELLO" });
}
Also used : Argument(gherkin.formatter.Argument) DocString(gherkin.formatter.model.DocString) DocString(gherkin.formatter.model.DocString) Step(gherkin.formatter.model.Step) LocalizedXStreams(cucumber.runtime.xstream.LocalizedXStreams) Test(org.junit.Test)

Example 14 with Step

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

the class StepDefinitionMatchTest method converts_numbers.

@Test
public void converts_numbers() throws Throwable {
    StepDefinition stepDefinition = mock(StepDefinition.class);
    when(stepDefinition.getParameterCount()).thenReturn(1);
    when(stepDefinition.getParameterType(0, String.class)).thenReturn(new ParameterInfo(Integer.TYPE, null, null, null));
    Step stepWithoutDocStringOrTable = mock(Step.class);
    when(stepWithoutDocStringOrTable.getDocString()).thenReturn(null);
    when(stepWithoutDocStringOrTable.getRows()).thenReturn(null);
    StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(Arrays.asList(new Argument(0, "5")), stepDefinition, "some.feature", stepWithoutDocStringOrTable, new LocalizedXStreams(classLoader));
    stepDefinitionMatch.runStep(ENGLISH);
    verify(stepDefinition).execute(ENGLISH, new Object[] { 5 });
}
Also used : Argument(gherkin.formatter.Argument) Step(gherkin.formatter.model.Step) LocalizedXStreams(cucumber.runtime.xstream.LocalizedXStreams) Test(org.junit.Test)

Example 15 with Step

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

the class CucumberScenarioOutlineTest method replaces_tokens_in_data_tables.

@Test
public void replaces_tokens_in_data_tables() {
    List<DataTableRow> rows = asList(new DataTableRow(C, asList("I", "have <n> cukes"), 1));
    Step outlineStep = new Step(C, null, "I have <n> cukes", 0, rows, null);
    Step exampleStep = CucumberScenarioOutline.createExampleStep(outlineStep, new ExamplesTableRow(C, asList("n"), 1, ""), new ExamplesTableRow(C, asList("10"), 1, ""));
    assertEquals(asList("I", "have 10 cukes"), 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)

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