use of cucumber.runtime.model.CucumberFeature 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);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class RerunFormatterTest method should_one_entry_for_feature_with_many_failing_scenarios.
@Test
public void should_one_entry_for_feature_with_many_failing_scenarios() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature name\n" + " Scenario: scenario 1 name\n" + " When first step\n" + " Then second step\n" + " Scenario: scenario 2 name\n" + " When third step\n" + " Then forth step\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("first step", result("passed"));
stepsToResult.put("second step", result("failed"));
stepsToResult.put("third step", result("failed"));
stepsToResult.put("forth step", result("passed"));
String formatterOutput = runFeatureWithRerunFormatter(feature, stepsToResult);
assertEquals("path/test.feature:2:5", formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class RerunFormatterTest method should_use_example_row_location_when_scenario_outline_fails.
@Test
public void should_use_example_row_location_when_scenario_outline_fails() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature name\n" + " Scenario Outline: scenario name\n" + " When executing <row> row\n" + " Then everything is ok\n" + " Examples:\n" + " | row |\n" + " | first |\n" + " | second |");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("executing first row", result("passed"));
stepsToResult.put("executing second row", result("failed"));
stepsToResult.put("everything is ok", result("passed"));
String formatterOutput = runFeatureWithRerunFormatter(feature, stepsToResult);
assertEquals("path/test.feature:8", formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project cucumber-jvm by cucumber.
the class RerunFormatterTest method should_one_entry_for_each_failing_feature.
@Test
public void should_one_entry_for_each_failing_feature() throws Throwable {
CucumberFeature feature1 = TestHelper.feature("path/first.feature", "" + "Feature: feature 1 name\n" + " Scenario: scenario 1 name\n" + " When first step\n" + " Then second step\n");
CucumberFeature feature2 = TestHelper.feature("path/second.feature", "" + "Feature: feature 2 name\n" + " Scenario: scenario 2 name\n" + " When third step\n" + " Then forth step\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("first step", result("passed"));
stepsToResult.put("second step", result("failed"));
stepsToResult.put("third step", result("failed"));
stepsToResult.put("forth step", result("passed"));
String formatterOutput = runFeaturesWithRerunFormatter(Arrays.asList(feature1, feature2), stepsToResult);
assertEquals("path/second.feature:2 path/first.feature:2", formatterOutput);
}
use of cucumber.runtime.model.CucumberFeature in project activityinfo by bedatadriven.
the class TestMain method queueFeatures.
private void queueFeatures(String environment, ResourceLoader loader, RuntimeOptions options, Module... driverModules) {
List<Module> modules = new ArrayList<>();
modules.add(new SystemUnderTest(url));
modules.add(new EmailModule());
modules.addAll(Arrays.asList(driverModules));
TestConditions conditions = new TestConditions(environment, modules);
Predicate<String> filter = filterPredicate();
List<CucumberFeature> features = options.cucumberFeatures(loader);
for (CucumberFeature feature : features) {
for (CucumberTagStatement element : feature.getFeatureElements()) {
if (filter.apply(feature.getPath()) || filter.apply(element.getVisualName())) {
ScenarioTestCase testCase = new ScenarioTestCase(options, feature, element, conditions);
queueTestCase(testCase);
}
}
}
}
Aggregations