use of gherkin.formatter.model.Result in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_format_passed_scenario.
@Test
public void should_format_passed_scenario() 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"));
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=\"1\" time=\"0.003\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.003\">\n" + " <system-out><![CDATA[" + "Given first step............................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}
use of gherkin.formatter.model.Result in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_accumulate_time_from_steps_and_hooks.
@Test
public void should_accumulate_time_from_steps_and_hooks() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Scenario: scenario name\n" + " * first step\n" + " * second step\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("first step", result("passed"));
stepsToResult.put("second step", result("passed"));
List<SimpleEntry<String, Result>> hooks = new ArrayList<SimpleEntry<String, Result>>();
hooks.add(TestHelper.hookEntry("before", result("passed")));
hooks.add(TestHelper.hookEntry("after", result("passed")));
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=\"0\" tests=\"1\" time=\"0.004\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.004\">\n" + " <system-out><![CDATA[" + "* first step................................................................passed\n" + "* second step...............................................................passed\n" + "]]></system-out>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}
use of gherkin.formatter.model.Result in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_handle_failure_in_before_hook_with_background.
@Test
public void should_handle_failure_in_before_hook_with_background() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "Feature: feature name\n" + " Background: background name\n" + " Given first step\n" + " Scenario: scenario name\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")));
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.001\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.001\">\n" + " <failure message=\"the stack trace\"><![CDATA[" + "Given first step............................................................skipped\n" + "When second step............................................................skipped\n" + "Then third step.............................................................skipped\n" + "\n" + "StackTrace:\n" + "the stack trace" + "]]></failure>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}
use of gherkin.formatter.model.Result in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_format_pending_scenario.
@Test
public void should_format_pending_scenario() 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("pending"));
stepsToResult.put("second step", result("skipped"));
stepsToResult.put("third step", result("undefined"));
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=\"1\" tests=\"1\" time=\"0.001\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.001\">\n" + " <skipped><![CDATA[" + "Given first step............................................................pending\n" + "When second step............................................................skipped\n" + "Then third step.............................................................undefined\n" + "]]></skipped>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}
use of gherkin.formatter.model.Result in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method should_format_failed_scenario.
@Test
public void should_format_failed_scenario() 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"));
long stepDuration = milliSeconds(1);
String formatterOutput = runFeatureWithJUnitFormatter(feature, stepsToResult, stepDuration);
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.003\">\n" + " <testcase classname=\"feature name\" name=\"scenario name\" time=\"0.003\">\n" + " <failure message=\"the stack trace\"><![CDATA[" + "Given first step............................................................passed\n" + "When second step............................................................passed\n" + "Then third step.............................................................failed\n" + "\n" + "StackTrace:\n" + "the stack trace" + "]]></failure>\n" + " </testcase>\n" + "</testsuite>\n";
assertXmlEqual(expected, formatterOutput);
}
Aggregations