Search in sources :

Example 21 with Result

use of gherkin.formatter.model.Result in project cucumber-jvm by cucumber.

the class RerunFormatterTest method should_use_scenario_location_when_background_step_fails.

@Test
public void should_use_scenario_location_when_background_step_fails() throws Throwable {
    CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature name\n" + "  Background: the background\n" + "    Given background step\n" + "  Scenario: scenario name\n" + "    When second step\n" + "    Then third step\n");
    Map<String, Result> stepsToResult = new HashMap<String, Result>();
    stepsToResult.put("background step", result("failed"));
    stepsToResult.put("second step", result("passed"));
    stepsToResult.put("third step", result("passed"));
    String formatterOutput = runFeatureWithRerunFormatter(feature, stepsToResult);
    assertEquals("path/test.feature:4", formatterOutput);
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) HashMap(java.util.HashMap) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 22 with Result

use of gherkin.formatter.model.Result in project cucumber-jvm by cucumber.

the class RerunFormatterTest method should_use_scenario_location_when_after_hook_fails.

@Test
public void should_use_scenario_location_when_after_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("after", result("failed")));
    String formatterOutput = runFeatureWithRerunFormatter(feature, stepsToResult, hooks);
    assertEquals("path/test.feature:2", formatterOutput);
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) HashMap(java.util.HashMap) SimpleEntry(java.util.AbstractMap.SimpleEntry) ArrayList(java.util.ArrayList) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 23 with Result

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

Example 24 with Result

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

Example 25 with Result

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

Aggregations

Result (gherkin.formatter.model.Result)75 Test (org.junit.Test)58 CucumberFeature (cucumber.runtime.model.CucumberFeature)32 HashMap (java.util.HashMap)32 Reporter (gherkin.formatter.Reporter)11 SimpleEntry (java.util.AbstractMap.SimpleEntry)10 ArrayList (java.util.ArrayList)10 Match (gherkin.formatter.model.Match)9 EachTestNotifier (org.junit.internal.runners.model.EachTestNotifier)8 Test (org.testng.annotations.Test)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 PrintStream (java.io.PrintStream)6 PendingException (cucumber.api.PendingException)5 Matchers.anyString (org.mockito.Matchers.anyString)4 StepDefinitionMatch (cucumber.runtime.StepDefinitionMatch)3 Scenario (gherkin.formatter.model.Scenario)3 List (java.util.List)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Given (cucumber.api.java.en.Given)2 DocString (gherkin.formatter.model.DocString)2