Search in sources :

Example 11 with Reporter

use of gherkin.formatter.Reporter in project cucumber-jvm by cucumber.

the class RuntimeTest method should_add_ambiguous_match_as_failed_result_to_the_summary_counter.

@Test
public void should_add_ambiguous_match_as_failed_result_to_the_summary_counter() throws Throwable {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Reporter reporter = mock(Reporter.class);
    Runtime runtime = createRuntimeWithMockedGlueWithAmbiguousMatch("--monochrome");
    runScenario(reporter, runtime, stepCount(1));
    runtime.printStats(new PrintStream(baos));
    assertThat(baos.toString(), containsString(String.format("" + "1 Scenarios (1 failed)%n" + "1 Steps (1 failed)%n")));
}
Also used : PrintStream(java.io.PrintStream) StepDefinitionReporter(cucumber.api.StepDefinitionReporter) Reporter(gherkin.formatter.Reporter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 12 with Reporter

use of gherkin.formatter.Reporter 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)

Example 13 with Reporter

use of gherkin.formatter.Reporter in project cucumber-jvm by cucumber.

the class JUnitReporterTest method createReporter.

private void createReporter(boolean strict, boolean allowStartedIgnored) {
    Formatter formatter = mock(Formatter.class);
    Reporter reporter = mock(Reporter.class);
    String allowStartedIgnoredOption = allowStartedIgnored ? "--allow-started-ignored" : "--no-allow-started-ignored";
    jUnitReporter = new JUnitReporter(reporter, formatter, strict, new JUnitOptions(asList(allowStartedIgnoredOption)));
}
Also used : Formatter(gherkin.formatter.Formatter) Reporter(gherkin.formatter.Reporter)

Example 14 with Reporter

use of gherkin.formatter.Reporter 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 15 with Reporter

use of gherkin.formatter.Reporter in project cucumber-jvm by cucumber.

the class JavaStepDefinitionTest method throws_ambiguous_when_two_matches_are_found.

@Test
public void throws_ambiguous_when_two_matches_are_found() throws Throwable {
    backend.addStepDefinition(THREE_DISABLED_MICE.getAnnotation(Given.class), THREE_DISABLED_MICE);
    backend.addStepDefinition(THREE_BLIND_ANIMALS.getAnnotation(Given.class), THREE_BLIND_ANIMALS);
    Reporter reporter = mock(Reporter.class);
    runtime.buildBackendWorlds(reporter, Collections.<Tag>emptySet(), mock(Scenario.class));
    Tag tag = new Tag("@foo", 0);
    runtime.runBeforeHooks(reporter, asSet(tag));
    runtime.runStep("some.feature", new Step(NO_COMMENTS, "Given ", "three blind mice", 1, null, null), reporter, ENGLISH);
    ArgumentCaptor<Result> result = ArgumentCaptor.forClass(Result.class);
    verify(reporter).result(result.capture());
    assertEquals(AmbiguousStepDefinitionsException.class, result.getValue().getError().getClass());
}
Also used : Given(cucumber.api.java.en.Given) Reporter(gherkin.formatter.Reporter) Tag(gherkin.formatter.model.Tag) Step(gherkin.formatter.model.Step) Scenario(gherkin.formatter.model.Scenario) Result(gherkin.formatter.model.Result) Test(org.junit.Test)

Aggregations

Reporter (gherkin.formatter.Reporter)15 Test (org.junit.Test)11 StepDefinitionReporter (cucumber.api.StepDefinitionReporter)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 PrintStream (java.io.PrintStream)8 Result (gherkin.formatter.model.Result)4 PendingException (cucumber.api.PendingException)3 Formatter (gherkin.formatter.Formatter)3 Match (gherkin.formatter.model.Match)3 Scenario (gherkin.formatter.model.Scenario)3 Given (cucumber.api.java.en.Given)2 CucumberFeature (cucumber.runtime.model.CucumberFeature)2 Step (gherkin.formatter.model.Step)2 Tag (gherkin.formatter.model.Tag)2 IOException (java.io.IOException)2 AssumptionViolatedException (org.junit.internal.AssumptionViolatedException)2 RunNotifier (org.junit.runner.notification.RunNotifier)1 Test (org.testng.annotations.Test)1