use of gherkin.I18n in project cucumber-jvm by cucumber.
the class StepDefinitionMatchTest method throws_arity_mismatch_exception_when_there_are_fewer_parameters_than_arguments.
@Test
public void throws_arity_mismatch_exception_when_there_are_fewer_parameters_than_arguments() throws Throwable {
Step step = new Step(null, "Given ", "I have 4 cukes in my belly", 1, null, null);
StepDefinition stepDefinition = new StubStepDefinition(new Object(), Object.class.getMethod("toString"), "some pattern");
StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(asList(new Argument(7, "4")), stepDefinition, null, step, new LocalizedXStreams(getClass().getClassLoader()));
try {
stepDefinitionMatch.runStep(new I18n("en"));
fail();
} catch (CucumberException expected) {
assertEquals("Arity mismatch: Step Definition 'toString' with pattern [some pattern] is declared with 0 parameters. However, the gherkin step has 1 arguments [4]. \n" + "Step: Given I have 4 cukes in my belly", expected.getMessage());
}
}
use of gherkin.I18n in project cucumber-jvm by cucumber.
the class StepDefinitionMatchTest method throws_arity_mismatch_exception_when_there_are_more_parameters_than_arguments.
@Test
public void throws_arity_mismatch_exception_when_there_are_more_parameters_than_arguments() throws Throwable {
Step step = new Step(null, "Given ", "I have 4 cukes in my belly", 1, new ArrayList<DataTableRow>(), null);
StepDefinition stepDefinition = new StubStepDefinition(new Object(), WithTwoParams.class.getMethod("withTwoParams", Integer.TYPE, Short.TYPE, List.class), "some pattern");
StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(asList(new Argument(7, "4")), stepDefinition, null, step, new LocalizedXStreams(getClass().getClassLoader()));
try {
stepDefinitionMatch.runStep(new I18n("en"));
fail();
} catch (CucumberException expected) {
assertEquals("Arity mismatch: Step Definition 'withTwoParams' with pattern [some pattern] is declared with 3 parameters. However, the gherkin step has 2 arguments [4, Table:[]]. \n" + "Step: Given I have 4 cukes in my belly", expected.getMessage());
}
}
use of gherkin.I18n in project cucumber-jvm by cucumber.
the class RuntimeTest method runStep.
public void runStep(Reporter reporter, Runtime runtime) {
Step step = mock(Step.class);
I18n i18n = mock(I18n.class);
runtime.runStep("<featurePath>", step, reporter, i18n);
}
use of gherkin.I18n in project cucumber-jvm by cucumber.
the class FeatureBuilder method parse.
public void parse(Resource resource, List<Object> filters) {
String gherkin = read(resource);
String checksum = checksum(gherkin);
String path = pathsByChecksum.get(checksum);
if (path != null) {
return;
}
pathsByChecksum.put(checksum, resource.getPath());
Formatter formatter = this;
if (!filters.isEmpty()) {
formatter = new FilterFormatter(this, filters);
}
Parser parser = new Parser(formatter);
try {
parser.parse(gherkin, convertFileSeparatorToForwardSlash(resource.getPath()), 0);
} catch (Exception e) {
throw new CucumberException(String.format("Error parsing feature file %s", convertFileSeparatorToForwardSlash(resource.getPath())), e);
}
I18n i18n = parser.getI18nLanguage();
if (currentCucumberFeature != null) {
// The current feature may be null if we used a very restrictive filter, say a tag that isn't used.
// Might also happen if the feature file itself is empty.
currentCucumberFeature.setI18n(i18n);
}
}
use of gherkin.I18n 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;
}
Aggregations