Search in sources :

Example 41 with Result

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

the class JUnitReporterTest method before_with_pending_exception_strict.

@Test
public void before_with_pending_exception_strict() {
    createStrictReporter();
    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.before(match, result);
    verifyAddFailureWithPendingException(executionUnitNotifier);
}
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 42 with Result

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

the class JUnitReporterTest method resultWithError.

@Test
public void resultWithError() {
    createNonStrictReporter();
    Result result = mock(Result.class);
    Throwable exception = mock(Throwable.class);
    when(result.getError()).thenReturn(exception);
    Description description = mock(Description.class);
    createRunNotifier(description);
    jUnitReporter.result(result);
    ArgumentCaptor<Failure> failureArgumentCaptor = ArgumentCaptor.forClass(Failure.class);
    verify(runNotifier).fireTestFailure(failureArgumentCaptor.capture());
    Failure failure = failureArgumentCaptor.getValue();
    assertEquals(description, failure.getDescription());
    assertEquals(exception, failure.getException());
}
Also used : Description(org.junit.runner.Description) Failure(org.junit.runner.notification.Failure) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 43 with Result

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

the class JUnitReporterTest method mockResult.

private Result mockResult() {
    Result result = mock(Result.class);
    when(result.getStatus()).thenReturn("passed");
    return result;
}
Also used : Result(gherkin.formatter.model.Result)

Example 44 with Result

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

the class JUnitReporterTest method result_with_pending_step_strict.

@Test
public void result_with_pending_step_strict() {
    createStrictReporter();
    createDefaultRunNotifier();
    Result result = mock(Result.class);
    when(result.getError()).thenReturn(new PendingException());
    EachTestNotifier stepNotifier = mock(EachTestNotifier.class);
    jUnitReporter.stepNotifier = stepNotifier;
    EachTestNotifier executionUnitNotifier = mock(EachTestNotifier.class);
    jUnitReporter.executionUnitNotifier = executionUnitNotifier;
    jUnitReporter.result(result);
    verify(stepNotifier, times(1)).fireTestStarted();
    verify(stepNotifier, times(1)).fireTestFinished();
    verifyAddFailureWithPendingException(stepNotifier);
    verifyAddFailureWithPendingException(executionUnitNotifier);
    verify(stepNotifier, times(0)).fireTestIgnored();
}
Also used : EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier) PendingException(cucumber.api.PendingException) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Example 45 with Result

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

the class JUnitReporterTest method result_without_error_allow_stared_ignored.

@Test
public void result_without_error_allow_stared_ignored() {
    createAllowStartedIgnoredReporter();
    Result result = mock(Result.class);
    EachTestNotifier stepNotifier = mock(EachTestNotifier.class);
    jUnitReporter.stepNotifier = stepNotifier;
    jUnitReporter.result(result);
    verify(stepNotifier, times(0)).fireTestStarted();
    verify(stepNotifier).fireTestFinished();
    verify(stepNotifier, times(0)).addFailure(Matchers.<Throwable>any(Throwable.class));
    verify(stepNotifier, times(0)).fireTestIgnored();
}
Also used : EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier) 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