Search in sources :

Example 51 with Result

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

the class FeatureResultListenerTest method mockPassedResult.

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

Example 52 with Result

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

the class FeatureResultListenerTest method mockPendingResult.

private Result mockPendingResult() {
    Result result = mock(Result.class);
    when(result.getStatus()).thenReturn(FeatureResultListener.PENDING_STATUS);
    return result;
}
Also used : Result(gherkin.formatter.model.Result)

Example 53 with Result

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

the class FeatureResultListenerTest method should_forward_calls_to_reporter_interface_methods.

@Test
public void should_forward_calls_to_reporter_interface_methods() throws Exception {
    Match match = mock(Match.class);
    Result result = mockPassedResult();
    String mimeType = "mimeType";
    byte[] data = new byte[] { 1 };
    String text = "text";
    Reporter reporter = mock(Reporter.class);
    FeatureResultListener resultListener = new FeatureResultListener(reporter, false);
    resultListener.before(match, result);
    resultListener.match(match);
    resultListener.embedding(mimeType, data);
    resultListener.write(text);
    resultListener.result(result);
    resultListener.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 : Reporter(gherkin.formatter.Reporter) Match(gherkin.formatter.model.Match) Result(gherkin.formatter.model.Result) Test(org.testng.annotations.Test)

Example 54 with Result

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

the class FeatureResultListenerTest method should_collect_error_after_undefined.

@Test
public void should_collect_error_after_undefined() throws Exception {
    Result result = mockFailedResult();
    FeatureResultListener resultListener = new FeatureResultListener(mock(Reporter.class), true);
    resultListener.result(Result.UNDEFINED);
    resultListener.result(result);
    assertEquals(resultListener.getFirstError(), result.getError());
}
Also used : Reporter(gherkin.formatter.Reporter) Result(gherkin.formatter.model.Result) Test(org.testng.annotations.Test)

Example 55 with Result

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

the class FeatureResultListenerTest method should_collect_first_error.

@Test
public void should_collect_first_error() throws Exception {
    Result result = mockFailedResult();
    FeatureResultListener resultListener = new FeatureResultListener(mock(Reporter.class), false);
    resultListener.result(result);
    resultListener.result(mockFailedResult());
    resultListener.result(mockPendingResult());
    resultListener.result(Result.UNDEFINED);
    assertEquals(resultListener.getFirstError(), result.getError());
}
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