use of gherkin.formatter.model.Result 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());
}
use of gherkin.formatter.model.Result in project cucumber-jvm by cucumber.
the class TestHelper method mockSteps.
private static void mockSteps(RuntimeGlue glue, Map<String, Result> stepsToResult, Map<String, String> stepsToLocation) throws Throwable {
for (String stepName : mergeStepSets(stepsToResult, stepsToLocation)) {
Result stepResult = getResultWithDefaultPassed(stepsToResult, stepName);
if (!"undefined".equals(stepResult.getStatus())) {
StepDefinitionMatch matchStep = mock(StepDefinitionMatch.class);
when(glue.stepDefinitionMatch(anyString(), TestHelper.stepWithName(stepName), (I18n) any())).thenReturn(matchStep);
mockStepResult(stepResult, matchStep);
mockStepLocation(getLocationWithDefaultEmptyString(stepsToLocation, stepName), matchStep);
}
}
}
use of gherkin.formatter.model.Result in project cucumber-jvm by cucumber.
the class TestNGFormatterTest method testScenarioWithUndefinedStepsStrict.
@Test
public void testScenarioWithUndefinedStepsStrict() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature\n" + " Scenario: scenario\n" + " When step\n" + " Then step\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("step", result("undefined"));
long stepDuration = milliSeconds(0);
String actual = runFeatureWithStrictTestNGFormatter(feature, stepsToResult, stepDuration);
assertXmlEqual("" + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<testng-results total=\"1\" passed=\"0\" failed=\"1\" skipped=\"0\">" + " <suite name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <test name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <class name=\"feature\">" + " <test-method name=\"scenario\" status=\"FAIL\" duration-ms=\"0\" started-at=\"yyyy-MM-ddTHH:mm:ssZ\" finished-at=\"yyyy-MM-ddTHH:mm:ssZ\">" + " <exception class=\"The scenario has pending or undefined step(s)\">" + " <message><![CDATA[When step...................................................................undefined\n" + "Then step...................................................................undefined\n" + "]]></message>" + " <full-stacktrace><![CDATA[The scenario has pending or undefined step(s)]]></full-stacktrace>" + " </exception>" + " </test-method>" + " </class>" + " </test>" + " </suite>" + "</testng-results>", actual);
}
use of gherkin.formatter.model.Result in project cucumber-jvm by cucumber.
the class TestNGFormatterTest method testScenarioOutlineWithExamples.
@Test
public void testScenarioOutlineWithExamples() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature\n" + " Scenario Outline: scenario\n" + " When step\n" + " Then step\n" + " Examples:\n" + " | arg |\n" + " | 1 |\n" + " | 2 |\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("step", result("undefined"));
long stepDuration = milliSeconds(0);
String actual = runFeatureWithTestNGFormatter(feature, stepsToResult, stepDuration);
assertXmlEqual("" + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<testng-results total=\"2\" passed=\"0\" failed=\"0\" skipped=\"2\">" + " <suite name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <test name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <class name=\"feature\">" + " <test-method name=\"scenario\" status=\"SKIP\" duration-ms=\"0\" started-at=\"yyyy-MM-ddTHH:mm:ssZ\" finished-at=\"yyyy-MM-ddTHH:mm:ssZ\"/>" + " <test-method name=\"scenario_2\" status=\"SKIP\" duration-ms=\"0\" started-at=\"yyyy-MM-ddTHH:mm:ssZ\" finished-at=\"yyyy-MM-ddTHH:mm:ssZ\"/>" + " </class>" + " </test>" + " </suite>" + "</testng-results>", actual);
}
use of gherkin.formatter.model.Result in project cucumber-jvm by cucumber.
the class TestNGFormatterTest method testScenarioWithFailedBeforeHook.
@Test
public void testScenarioWithFailedBeforeHook() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature\n" + " Scenario: scenario\n" + " When step\n" + " Then step\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("step", result("skipped"));
List<SimpleEntry<String, Result>> hooks = new ArrayList<SimpleEntry<String, Result>>();
hooks.add(TestHelper.hookEntry("before", result("failed", new TestNGException("message", "stacktrace"))));
long stepHookDuration = milliSeconds(0);
String actual = runFeatureWithTestNGFormatter(feature, stepsToResult, hooks, stepHookDuration);
assertXmlEqual("" + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + "<testng-results total=\"1\" passed=\"0\" failed=\"1\" skipped=\"0\">" + " <suite name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <test name=\"cucumber.runtime.formatter.TestNGFormatter\" duration-ms=\"0\">" + " <class name=\"feature\">" + " <test-method name=\"scenario\" status=\"FAIL\" duration-ms=\"0\" started-at=\"yyyy-MM-ddTHH:mm:ssZ\" finished-at=\"yyyy-MM-ddTHH:mm:ssZ\">" + " <exception class=\"cucumber.runtime.formatter.TestNGFormatterTest$TestNGException\">" + " <message><![CDATA[When step...................................................................skipped\n" + "Then step...................................................................skipped\n" + "]]></message>" + " <full-stacktrace><![CDATA[stacktrace]]></full-stacktrace>" + " </exception>" + " </test-method>" + " </class>" + " </test>" + " </suite>" + "</testng-results>", actual);
}
Aggregations