Search in sources :

Example 36 with Result

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

the class ScenarioResultTest method passed_and_skipped_is_skipped_although_we_cant_have_skipped_without_undefined_or_pending.

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

Example 37 with Result

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

the class ScenarioResultTest method passed_undefined_skipped_is_undefined.

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

Example 38 with Result

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

the class Runtime method runHookIfTagsMatch.

private void runHookIfTagsMatch(HookDefinition hook, Reporter reporter, Set<Tag> tags, boolean isBefore) {
    if (hook.matches(tags)) {
        String status = Result.PASSED;
        Throwable error = null;
        Match match = new Match(Collections.<Argument>emptyList(), hook.getLocation(false));
        stopWatch.start();
        try {
            hook.execute(scenarioResult);
        } catch (Throwable t) {
            error = t;
            status = isPending(t) ? "pending" : Result.FAILED;
            addError(t);
            skipNextStep = true;
        } finally {
            long duration = stopWatch.stop();
            Result result = new Result(status, duration, error, DUMMY_ARG);
            addHookToCounterAndResult(result);
            if (isBefore) {
                reporter.before(match, result);
            } else {
                reporter.after(match, result);
            }
        }
    }
}
Also used : DocString(gherkin.formatter.model.DocString) Match(gherkin.formatter.model.Match) Result(gherkin.formatter.model.Result)

Example 39 with Result

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

the class JUnitReporterTest method after_with_pending_exception_non_strict.

@Test
public void after_with_pending_exception_non_strict() {
    createNonStrictReporter();
    createDefaultRunNotifier();
    Result result = mock(Result.class);
    Match match = mock(Match.class);
    when(result.getStatus()).thenReturn("Pending");
    when(result.getError()).thenReturn(new PendingException());
    EachTestNotifier executionUnitNotifier = mock(EachTestNotifier.class);
    jUnitReporter.executionUnitNotifier = executionUnitNotifier;
    jUnitReporter.after(match, result);
    jUnitReporter.finishExecutionUnit();
    verify(executionUnitNotifier).fireTestIgnored();
}
Also used : EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier) PendingException(cucumber.api.PendingException) Result(gherkin.formatter.model.Result) Match(gherkin.formatter.model.Match) Test(org.junit.Test)

Example 40 with Result

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

the class JUnitReporterTest method forward_calls_to_reporter_interface_methods.

@Test
public void forward_calls_to_reporter_interface_methods() throws Exception {
    Match match = mock(Match.class);
    Result result = mockResult();
    ExecutionUnitRunner executionUnitRunner = mockExecutionUnitRunner();
    String mimeType = "mimeType";
    byte[] data = new byte[] { 1 };
    String text = "text";
    Reporter reporter = mock(Reporter.class);
    jUnitReporter = new JUnitReporter(reporter, mock(Formatter.class), false, new JUnitOptions(Collections.<String>emptyList()));
    jUnitReporter.startExecutionUnit(executionUnitRunner, mock(RunNotifier.class));
    jUnitReporter.startOfScenarioLifeCycle(mock(Scenario.class));
    jUnitReporter.before(match, result);
    jUnitReporter.step(mockStep());
    jUnitReporter.match(match);
    jUnitReporter.embedding(mimeType, data);
    jUnitReporter.write(text);
    jUnitReporter.result(result);
    jUnitReporter.after(match, result);
    verify(reporter).before(match, result);
    verify(reporter).match(match);
    verify(reporter).embedding(mimeType, data);
    verify(reporter).write(text);
    verify(reporter).result(result);
    verify(reporter).after(match, result);
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Reporter(gherkin.formatter.Reporter) Match(gherkin.formatter.model.Match) Result(gherkin.formatter.model.Result) Scenario(gherkin.formatter.model.Scenario) 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