Search in sources :

Example 71 with Result

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

the class PluginFactoryTest method plugin_does_not_buffer_its_output.

@Test
public void plugin_does_not_buffer_its_output() throws IOException {
    PrintStream previousSystemOut = System.out;
    OutputStream mockSystemOut = new ByteArrayOutputStream();
    try {
        System.setOut(new PrintStream(mockSystemOut));
        // Need to create a new plugin factory here since we need it to pick up the new value of System.out
        fc = new PluginFactory();
        ProgressFormatter plugin = (ProgressFormatter) fc.create("progress");
        plugin.result(new Result("passed", null, null));
        assertThat(mockSystemOut.toString(), is(not("")));
    } finally {
        System.setOut(previousSystemOut);
    }
}
Also used : PrintStream(java.io.PrintStream) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 72 with Result

use of gherkin.formatter.model.Result 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 73 with Result

use of gherkin.formatter.model.Result 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 74 with Result

use of gherkin.formatter.model.Result 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 75 with Result

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

the class StatsTest method should_print_minutes_seconds_and_milliseconds.

@Test
public void should_print_minutes_seconds_and_milliseconds() {
    Stats counter = createMonochromeSummaryCounter();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    counter.addStep(new Result(Result.PASSED, Stats.ONE_MINUTE, null));
    counter.addStep(new Result(Result.PASSED, Stats.ONE_SECOND, null));
    counter.addStep(new Result(Result.PASSED, ONE_MILLI_SECOND, null));
    counter.printStats(new PrintStream(baos), isStrict(false));
    assertThat(baos.toString(), endsWith(String.format("1m1.001s%n")));
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) 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