Search in sources :

Example 46 with Result

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

the class JUnitReporterTest method result_with_pending_step_non_strict.

@Test
public void result_with_pending_step_non_strict() {
    createNonStrictReporter();
    Result result = mock(Result.class);
    when(result.getError()).thenReturn(new PendingException());
    EachTestNotifier stepNotifier = mock(EachTestNotifier.class);
    jUnitReporter.stepNotifier = stepNotifier;
    jUnitReporter.result(result);
    verify(stepNotifier, times(0)).fireTestStarted();
    verify(stepNotifier, times(0)).fireTestFinished();
    verify(stepNotifier, times(0)).addFailure(Matchers.<Throwable>any(Throwable.class));
    verify(stepNotifier).fireTestIgnored();
}
Also used : EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier) PendingException(cucumber.api.PendingException) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 47 with Result

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

the class JUnitReporterTest method failed_step_and_after_with_pending_exception_non_strict.

@Test
public void failed_step_and_after_with_pending_exception_non_strict() {
    createNonStrictReporter();
    createDefaultRunNotifier();
    Result stepResult = mock(Result.class);
    Throwable exception = mock(Throwable.class);
    when(stepResult.getError()).thenReturn(exception);
    Result hookResult = mock(Result.class);
    Match match = mock(Match.class);
    when(hookResult.getStatus()).thenReturn("Pending");
    when(hookResult.getError()).thenReturn(new PendingException());
    EachTestNotifier executionUnitNotifier = mock(EachTestNotifier.class);
    jUnitReporter.executionUnitNotifier = executionUnitNotifier;
    jUnitReporter.result(stepResult);
    jUnitReporter.after(match, hookResult);
    jUnitReporter.finishExecutionUnit();
    verify(executionUnitNotifier, times(0)).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 48 with Result

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

the class FeatureResultListenerTest method mockFailedResult.

private Result mockFailedResult() {
    Result result = mock(Result.class);
    when(result.getStatus()).thenReturn(Result.FAILED);
    when(result.getError()).thenReturn(mock(Throwable.class));
    return result;
}
Also used : Result(gherkin.formatter.model.Result)

Example 49 with Result

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

the class FeatureResultListenerTest method should_not_be_passed_for_failed_before_hook.

@Test
public void should_not_be_passed_for_failed_before_hook() throws Exception {
    Result result = mockFailedResult();
    FeatureResultListener resultListener = new FeatureResultListener(mock(Reporter.class), false);
    resultListener.before(mock(Match.class), result);
    assertFalse(resultListener.isPassed());
    assertEquals(resultListener.getFirstError(), result.getError());
}
Also used : Reporter(gherkin.formatter.Reporter) Result(gherkin.formatter.model.Result) Match(gherkin.formatter.model.Match) Test(org.testng.annotations.Test)

Example 50 with Result

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

the class FeatureResultListenerTest method should_collect_pending_after_undefined.

@Test
public void should_collect_pending_after_undefined() throws Exception {
    Result result = mockPendingResult();
    FeatureResultListener resultListener = new FeatureResultListener(mock(Reporter.class), true);
    resultListener.result(Result.UNDEFINED);
    resultListener.result(result);
    assertEquals(resultListener.getFirstError().getMessage(), FeatureResultListener.PENDING_MESSAGE);
}
Also used : Reporter(gherkin.formatter.Reporter) Result(gherkin.formatter.model.Result) Test(org.testng.annotations.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