use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_add_dummy_testcase_if_no_scenarios_are_run_to_aviod_failed_jenkins_jobs.
@Test
public void should_add_dummy_testcase_if_no_scenarios_are_run_to_aviod_failed_jenkins_jobs() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n");
String formatterOutput = runFeatureWithJUnitFormatter(feature);
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" time=\"0\">\n" + " <testcase classname=\"dummy\" name=\"dummy\">\n" + " <skipped message=\"No features found\" />\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_format_scenario_outlines_with_arguments_in_name.
@Test
public void should_format_scenario_outlines_with_arguments_in_name() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario Outline: outline name <arg>\n" + " Given first step \"<arg>\"\n" + " When second step\n" + " Then third step\n\n" + " Examples: examples 1\n" + " | arg |\n" + " | a |\n" + " | b |\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"));
long stepDuration = milliSeconds(1);
String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, stepDuration);
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"2\" time=\"0.006\">\n" + " <testcase classname=\"feature name\" name=\"outline name a\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"a\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + " <testcase classname=\"feature name\" name=\"outline name b\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"b\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_handle_pending_in_before_hook.
@Test
public void should_handle_pending_in_before_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("skipped"));
stepsToResult.put("second step", result("skipped"));
stepsToResult.put("third step", result("skipped"));
List<SimpleEntry<String, Result>> hooks = new ArrayList<SimpleEntry<String, Result>>();
hooks.add(TestHelper.hookEntry("before", result("pending")));
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=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"1\" tests=\"1\" time=\"0.001\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.001\">\n" + " <skipped><![CDATA[" + "Given first step............................................................skipped\n" + "When second step............................................................skipped\n" + "Then third step.............................................................skipped\n" + "]]></skipped>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_handle_empty_scenarios.
@Test
public void should_handle_empty_scenarios() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario: scenario name\n");
String formatterOutput = runFeatureWithJUnitFormatter(feature);
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"1\" tests=\"1\" time=\"0\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0\">\n" + " <skipped message=\"The scenario has no steps\" />\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_format_scenario_outlines.
@Test
public void should_format_scenario_outlines() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario Outline: outline_name\n" + " Given first step \"<arg>\"\n" + " When second step\n" + " Then third step\n\n" + " Examples: examples\n" + " | arg |\n" + " | a |\n" + " | b |\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"));
long stepDuration = milliSeconds(1);
String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, stepDuration);
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<testsuite failures=\"0\" name=\"cucumber.runtime.formatter.JUnitFormatter\" skipped=\"0\" tests=\"2\" time=\"0.006\">\n" + " <testcase classname=\"feature name\" name=\"outline_name\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"a\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + " <testcase classname=\"feature name\" name=\"outline_name_2\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step \"b\"........................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}
Aggregations