use of gherkin.formatter.Argument in project cucumber-jvm by cucumber.
the class StepDefinitionMatchTest method converts_with_explicit_converter.
@Test
public void converts_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 stepWithoutDocStringOrTable = mock(Step.class);
when(stepWithoutDocStringOrTable.getDocString()).thenReturn(null);
when(stepWithoutDocStringOrTable.getRows()).thenReturn(null);
StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(Arrays.asList(new Argument(0, "the thing")), stepDefinition, "some.feature", stepWithoutDocStringOrTable, new LocalizedXStreams(classLoader));
stepDefinitionMatch.runStep(ENGLISH);
verify(stepDefinition).execute(ENGLISH, new Object[] { new Thing("the thing") });
}
use of gherkin.formatter.Argument 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" });
}
use of gherkin.formatter.Argument 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") });
}
use of gherkin.formatter.Argument 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" });
}
use of gherkin.formatter.Argument 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 });
}
Aggregations