Search in sources :

Example 16 with Result

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

the class UsageFormatterTest method resultWithStep.

@Test
public void resultWithStep() {
    Appendable out = mock(Appendable.class);
    UsageFormatter usageFormatter = new UsageFormatter(out);
    StepDefinitionMatch match = mockStepDefinitionMatch();
    usageFormatter.match(match);
    Result result = mock(Result.class);
    when(result.getDuration()).thenReturn(12345L);
    when(result.getStatus()).thenReturn(Result.PASSED);
    usageFormatter.result(result);
    Map<String, List<UsageFormatter.StepContainer>> usageMap = usageFormatter.usageMap;
    assertEquals(usageMap.size(), 1);
    List<UsageFormatter.StepContainer> durationEntries = usageMap.get("stepDef");
    assertEquals(durationEntries.size(), 1);
    assertEquals(durationEntries.get(0).name, "step");
    assertEquals(durationEntries.get(0).durations.size(), 1);
    assertEquals(durationEntries.get(0).durations.get(0).duration, BigDecimal.valueOf(12345));
}
Also used : List(java.util.List) StepDefinitionMatch(cucumber.runtime.StepDefinitionMatch) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 17 with Result

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

the class RuntimeTest method runFeatureWithFormatterSpy.

private String runFeatureWithFormatterSpy(CucumberFeature feature, Map<String, Result> stepsToResult) throws Throwable {
    FormatterSpy formatterSpy = new FormatterSpy();
    TestHelper.runFeatureWithFormatter(feature, stepsToResult, Collections.<SimpleEntry<String, Result>>emptyList(), 0L, formatterSpy, formatterSpy);
    return formatterSpy.toString();
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) FormatterSpy(cucumber.runtime.formatter.FormatterSpy) Result(gherkin.formatter.model.Result)

Example 18 with Result

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

the class RuntimeTest method should_call_formatter_for_two_scenarios_with_background.

@Test
public void should_call_formatter_for_two_scenarios_with_background() throws Throwable {
    CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature name\n" + "  Background: background\n" + "    Given first step\n" + "  Scenario: scenario_1 name\n" + "    When second step\n" + "    Then third step\n" + "  Scenario: scenario_2 name\n" + "    Then second 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"));
    String formatterOutput = runFeatureWithFormatterSpy(feature, stepsToResult);
    assertEquals("" + "uri\n" + "feature\n" + "  startOfScenarioLifeCycle\n" + "  background\n" + "    step\n" + "    match\n" + "    result\n" + "  scenario\n" + "    step\n" + "    step\n" + "    match\n" + "    result\n" + "    match\n" + "    result\n" + "  endOfScenarioLifeCycle\n" + "  startOfScenarioLifeCycle\n" + "  background\n" + "    step\n" + "    match\n" + "    result\n" + "  scenario\n" + "    step\n" + "    match\n" + "    result\n" + "  endOfScenarioLifeCycle\n" + "eof\n" + "done\n" + "close\n", formatterOutput);
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 19 with Result

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

the class ScenarioResultTest method passed_failed_pending_undefined_skipped_is_failed.

@Test
public void passed_failed_pending_undefined_skipped_is_failed() throws Exception {
    s.add(new Result("passed", 0L, null, null));
    s.add(new Result("failed", 0L, null, null));
    s.add(new Result("pending", 0L, null, null));
    s.add(new Result("undefined", 0L, null, null));
    s.add(new Result("skipped", 0L, null, null));
    assertEquals("failed", s.getStatus());
}
Also used : Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 20 with Result

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

the class RerunFormatterTest method should_leave_report_empty_when_exit_code_is_zero.

@Test
public void should_leave_report_empty_when_exit_code_is_zero() throws Throwable {
    CucumberFeature feature = TestHelper.feature("path/test.feature", "" + "Feature: feature name\n" + "  Scenario: passed scenario\n" + "    Given passed 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("passed step", result("passed"));
    stepsToResult.put("pending step", result("pending"));
    stepsToResult.put("undefined step", result("undefined"));
    String formatterOutput = runFeatureWithRerunFormatter(feature, stepsToResult);
    assertEquals("", 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