use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class RerunFormatterTest method should_use_scenario_location_when_before_hook_fails.
@Test
public void should_use_scenario_location_when_before_hook_fails() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n" + " When second step\n" + " Then third step\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("first step", result("passed"));
stepsToResult.put("second step", result("passed"));
stepsToResult.put("third step", result("passed"));
List<SimpleEntry<String, Result>> hooks = new ArrayList<SimpleEntry<String, Result>>();
hooks.add(TestHelper.hookEntry("before", result("failed")));
String formatterOutput = runFeatureWithRerunFormatter(feature, stepsToResult, hooks);
assertEquals("path/test.feature:2", formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class RerunFormatterTest method should_use_scenario_location_when_scenario_step_fails.
@Test
public void should_use_scenario_location_when_scenario_step_fails() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n" + " When second step\n" + " Then third step\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("first step", result("passed"));
stepsToResult.put("second step", result("passed"));
stepsToResult.put("third step", result("failed"));
String formatterOutput = runFeatureWithRerunFormatter(feature, stepsToResult);
assertEquals("path/test.feature:2", formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class RerunFormatterTest method should_put_data_in_report_when_exit_code_is_non_zero.
@Test
public void should_put_data_in_report_when_exit_code_is_non_zero() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature name\n" + " Scenario: failed scenario\n" + " Given failed step\n" + " Scenario: pending scenario\n" + " Given pending step\n" + " Scenario: undefined scenario\n" + " Given undefined step\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("failed step", result("failed"));
stepsToResult.put("pending step", result("pending"));
stepsToResult.put("undefined step", result("undefined"));
String formatterOutput = runFeatureWithRerunFormatter(feature, stepsToResult, strict(true));
assertEquals("path/test.feature:2:4:6", formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class RuntimeTest method should_call_formatter_for_scenario_outline_with_two_examples_table_and_background.
@Test
public void should_call_formatter_for_scenario_outline_with_two_examples_table_and_background() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature name\n" + " Background: background\n" + " Given first step\n" + " Scenario Outline: scenario outline name\n" + " When <x> step\n" + " Then <y> step\n" + " Examples: examples 1 name\n" + " | x | y |\n" + " | second | third |\n" + " | second | third |\n" + " Examples: examples 2 name\n" + " | x | y |\n" + " | second | third |\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("first step", result("passed"));
stepsToResult.put("second step", result("passed"));
stepsToResult.put("third step", result("passed"));
String formatterOutput = runFeatureWithFormatterSpy(feature, stepsToResult);
assertEquals("" + "uri\n" + "feature\n" + " scenarioOutline\n" + " step\n" + " step\n" + " examples\n" + " startOfScenarioLifeCycle\n" + " background\n" + " step\n" + " match\n" + " result\n" + " scenario\n" + " step\n" + " step\n" + " match\n" + " result\n" + " match\n" + " result\n" + " endOfScenarioLifeCycle\n" + " startOfScenarioLifeCycle\n" + " background\n" + " step\n" + " match\n" + " result\n" + " scenario\n" + " step\n" + " step\n" + " match\n" + " result\n" + " match\n" + " result\n" + " endOfScenarioLifeCycle\n" + " examples\n" + " startOfScenarioLifeCycle\n" + " background\n" + " step\n" + " match\n" + " result\n" + " scenario\n" + " step\n" + " step\n" + " match\n" + " result\n" + " match\n" + " result\n" + " endOfScenarioLifeCycle\n" + "eof\n" + "done\n" + "close\n", formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_handle_failure_in_after_hook.
@Test
public void should_handle_failure_in_after_hook() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n" + " When second step\n" + " Then third step\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("first step", result("passed"));
stepsToResult.put("second step", result("passed"));
stepsToResult.put("third step", result("passed"));
List<SimpleEntry<String, Result>> hooks = new ArrayList<SimpleEntry<String, Result>>();
hooks.add(TestHelper.hookEntry("after", result("failed")));
long stepHookDuration = milliSeconds(1);
String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, hooks, stepHookDuration);
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"1\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"1\" time=\"0.004\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.004\">\n" + " <failure message=\"the stack trace\"><![CDATA[" + "Given first step............................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "\n" + "StackTrace:\n" + "the stack trace" + "]]></failure>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}
Aggregations