Search in sources :

Example 61 with CucumberFeature

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);
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) HashMap(java.util.HashMap) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 62 with CucumberFeature

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);
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) HashMap(java.util.HashMap) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 63 with CucumberFeature

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);
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) HashMap(java.util.HashMap) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 64 with CucumberFeature

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);
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) HashMap(java.util.HashMap) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 65 with CucumberFeature

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);
            }
        }
    }
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) SystemUnderTest(org.activityinfo.test.sut.SystemUnderTest) CucumberTagStatement(cucumber.runtime.model.CucumberTagStatement) OdkModule(org.activityinfo.test.webdriver.OdkModule) Module(com.google.inject.Module) ApiModule(org.activityinfo.test.driver.ApiModule) WebDriverModule(org.activityinfo.test.webdriver.WebDriverModule) EmailModule(org.activityinfo.test.driver.mail.EmailModule) EmailModule(org.activityinfo.test.driver.mail.EmailModule) ScenarioTestCase(org.activityinfo.test.cucumber.ScenarioTestCase)

Aggregations

CucumberFeature (cucumber.runtime.model.CucumberFeature)65 Test (org.junit.Test)53 HashMap (java.util.HashMap)33 Result (gherkin.formatter.model.Result)32 ArrayList (java.util.ArrayList)19 SimpleEntry (java.util.AbstractMap.SimpleEntry)10 ClasspathResourceLoader (cucumber.runtime.io.ClasspathResourceLoader)6 Resource (cucumber.runtime.io.Resource)6 Formatter (gherkin.formatter.Formatter)5 Reporter (gherkin.formatter.Reporter)5 StepDefinitionReporter (cucumber.api.StepDefinitionReporter)4 CucumberTagStatement (cucumber.runtime.model.CucumberTagStatement)4 Step (gherkin.formatter.model.Step)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Matchers.anyString (org.mockito.Matchers.anyString)4 CucumberJSONFormatter (cucumber.runtime.formatter.CucumberJSONFormatter)3 JSONFormatter (gherkin.formatter.JSONFormatter)3 Tag (gherkin.formatter.model.Tag)3 Description (org.junit.runner.Description)3 Scenario (cucumber.api.Scenario)2