Search in sources :

Example 6 with Reporter

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

the class JavaStepDefinitionTest method does_not_throw_ambiguous_when_nothing_is_ambiguous.

@Test
public void does_not_throw_ambiguous_when_nothing_is_ambiguous() throws Throwable {
    backend.addStepDefinition(THREE_DISABLED_MICE.getAnnotation(Given.class), THREE_DISABLED_MICE);
    Reporter reporter = new Reporter() {

        @Override
        public void before(Match match, Result result) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void result(Result result) {
            if (result.getError() != null) {
                throw new RuntimeException(result.getError());
            }
        }

        @Override
        public void after(Match match, Result result) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void match(Match match) {
        }

        @Override
        public void embedding(String mimeType, byte[] data) {
        }

        @Override
        public void write(String text) {
        }
    };
    runtime.buildBackendWorlds(reporter, Collections.<Tag>emptySet(), mock(Scenario.class));
    Tag tag = new Tag("@foo", 0);
    Set<Tag> tags = asSet(tag);
    runtime.runBeforeHooks(reporter, tags);
    Step step = new Step(NO_COMMENTS, "Given ", "three blind mice", 1, null, null);
    runtime.runStep("some.feature", step, reporter, ENGLISH);
    assertTrue(defs.foo);
    assertFalse(defs.bar);
}
Also used : Given(cucumber.api.java.en.Given) Reporter(gherkin.formatter.Reporter) Tag(gherkin.formatter.model.Tag) Step(gherkin.formatter.model.Step) Match(gherkin.formatter.model.Match) Result(gherkin.formatter.model.Result) Scenario(gherkin.formatter.model.Scenario) Test(org.junit.Test)

Example 7 with Reporter

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

the class CucumberExecutor method execute.

/**
     * Runs the cucumber scenarios with the specified arguments.
     */
public void execute() {
    runtimeOptions.addPlugin(new AndroidInstrumentationReporter(runtime, instrumentation, getNumberOfConcreteScenarios()));
    runtimeOptions.addPlugin(new AndroidLogcatReporter(runtime, TAG));
    // TODO: This is duplicated in info.cucumber.Runtime.
    final Reporter reporter = runtimeOptions.reporter(classLoader);
    final Formatter formatter = runtimeOptions.formatter(classLoader);
    final StepDefinitionReporter stepDefinitionReporter = runtimeOptions.stepDefinitionReporter(classLoader);
    runtime.getGlue().reportStepDefinitions(stepDefinitionReporter);
    for (final CucumberFeature cucumberFeature : cucumberFeatures) {
        cucumberFeature.run(formatter, reporter, runtime);
    }
    formatter.done();
    formatter.close();
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) Formatter(gherkin.formatter.Formatter) Reporter(gherkin.formatter.Reporter) StepDefinitionReporter(cucumber.api.StepDefinitionReporter) StepDefinitionReporter(cucumber.api.StepDefinitionReporter)

Example 8 with Reporter

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

the class RuntimeTest method should_add_skipped_result_to_the_summary_counter.

@Test
public void should_add_skipped_result_to_the_summary_counter() throws Throwable {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Reporter reporter = mock(Reporter.class);
    StepDefinitionMatch match = createExceptionThrowingMatch(new Exception());
    Runtime runtime = createRuntimeWithMockedGlue(match, "--monochrome");
    runScenario(reporter, runtime, stepCount(2));
    runtime.printStats(new PrintStream(baos));
    assertThat(baos.toString(), containsString(String.format("" + "1 Scenarios (1 failed)%n" + "2 Steps (1 failed, 1 skipped)%n")));
}
Also used : PrintStream(java.io.PrintStream) StepDefinitionReporter(cucumber.api.StepDefinitionReporter) Reporter(gherkin.formatter.Reporter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) PendingException(cucumber.api.PendingException) IOException(java.io.IOException) Test(org.junit.Test)

Example 9 with Reporter

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

the class RuntimeTest method should_add_passed_result_to_the_summary_counter.

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

Example 10 with Reporter

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

the class RuntimeTest method should_add_failed_result_to_the_summary_counter.

@Test
public void should_add_failed_result_to_the_summary_counter() throws Throwable {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Reporter reporter = mock(Reporter.class);
    StepDefinitionMatch match = createExceptionThrowingMatch(new Exception());
    Runtime runtime = createRuntimeWithMockedGlue(match, "--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) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) PendingException(cucumber.api.PendingException) IOException(java.io.IOException) 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