use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class Java8StepDefinitionTest method should_pass_for_param_with_generic_list.
@Test
public void should_pass_for_param_with_generic_list() throws Exception {
try {
StepdefBody body = (StepdefBody.A1<List<String>>) p1 -> {
};
new Java8StepDefinition(Pattern.compile("^I have (\\d) some step (.*)$"), 0, body, typeIntrospector);
} catch (CucumberException expected) {
assertEquals("Can't use java.util.List in lambda step definition. Declare a DataTable argument instead and convert manually with asList/asLists/asMap/asMaps", expected.getMessage());
}
}
use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class Java8StepDefinitionTest method should_fail_for_param_with_non_generic_list.
@Test
public void should_fail_for_param_with_non_generic_list() throws Exception {
try {
StepdefBody body = (StepdefBody.A1<List>) p1 -> {
};
new Java8StepDefinition(Pattern.compile("^I have (\\d) some step (.*)$"), 0, body, typeIntrospector);
} catch (CucumberException expected) {
assertEquals("Can't use java.util.List in lambda step definition. Declare a DataTable argument instead and convert manually with asList/asLists/asMap/asMaps", expected.getMessage());
}
}
use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class CucumberTest method testThatFileIsNotCreatedOnParsingError.
@Test
public void testThatFileIsNotCreatedOnParsingError() throws Exception {
try {
new Cucumber(FormatterWithLexerErrorFeature.class);
fail("Expecting error");
} catch (CucumberException e) {
assertFalse("File is created despite Lexor Error", new File("lexor_error_feature.json").exists());
}
}
use of cucumber.runtime.CucumberException 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");
}
}
use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class FeatureRunner method buildFeatureElementRunners.
private void buildFeatureElementRunners() {
for (CucumberTagStatement cucumberTagStatement : cucumberFeature.getFeatureElements()) {
try {
ParentRunner featureElementRunner;
if (cucumberTagStatement instanceof CucumberScenario) {
featureElementRunner = new ExecutionUnitRunner(runtime, (CucumberScenario) cucumberTagStatement, jUnitReporter);
} else {
featureElementRunner = new ScenarioOutlineRunner(runtime, (CucumberScenarioOutline) cucumberTagStatement, jUnitReporter);
}
children.add(featureElementRunner);
} catch (InitializationError e) {
throw new CucumberException("Failed to create scenario runner", e);
}
}
}
Aggregations