Search in sources :

Example 1 with Reporter

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

the class Runtime method run.

/**
     * This is the main entry point. Used from CLI, but not from JUnit.
     */
public void run() throws IOException {
    // Make sure all features parse before initialising any reporters/formatters
    List<CucumberFeature> features = runtimeOptions.cucumberFeatures(resourceLoader);
    // TODO: This is duplicated in cucumber.api.android.CucumberInstrumentationCore - refactor or keep uptodate
    Formatter formatter = runtimeOptions.formatter(classLoader);
    Reporter reporter = runtimeOptions.reporter(classLoader);
    StepDefinitionReporter stepDefinitionReporter = runtimeOptions.stepDefinitionReporter(classLoader);
    glue.reportStepDefinitions(stepDefinitionReporter);
    for (CucumberFeature cucumberFeature : features) {
        cucumberFeature.run(formatter, reporter, this);
    }
    formatter.done();
    formatter.close();
    printSummary();
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) Formatter(gherkin.formatter.Formatter) StepDefinitionReporter(cucumber.api.StepDefinitionReporter) Reporter(gherkin.formatter.Reporter) StepDefinitionReporter(cucumber.api.StepDefinitionReporter)

Example 2 with Reporter

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

the class RuntimeTest method should_fail_the_scenario_if_before_fails.

@Test
public void should_fail_the_scenario_if_before_fails() throws Throwable {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Reporter reporter = mock(Reporter.class);
    StepDefinitionMatch match = mock(StepDefinitionMatch.class);
    HookDefinition hook = createExceptionThrowingHook();
    Runtime runtime = createRuntimeWithMockedGlue(match, hook, true, "--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 skipped)%n")));
}
Also used : PrintStream(java.io.PrintStream) StepDefinitionReporter(cucumber.api.StepDefinitionReporter) Reporter(gherkin.formatter.Reporter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 3 with Reporter

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

the class RuntimeTest method should_fail_the_scenario_if_after_fails.

@Test
public void should_fail_the_scenario_if_after_fails() throws Throwable {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Reporter reporter = mock(Reporter.class);
    StepDefinitionMatch match = mock(StepDefinitionMatch.class);
    HookDefinition hook = createExceptionThrowingHook();
    Runtime runtime = createRuntimeWithMockedGlue(match, hook, false, "--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 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 4 with Reporter

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

the class RuntimeTest method should_add_pending_result_to_the_summary_counter.

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

Example 5 with Reporter

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

the class RuntimeTest method should_add_undefined_result_to_the_summary_counter.

@Test
public void should_add_undefined_result_to_the_summary_counter() throws Throwable {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Reporter reporter = mock(Reporter.class);
    Runtime runtime = createRuntimeWithMockedGlue(null, "--monochrome");
    runScenario(reporter, runtime, stepCount(1));
    runtime.printStats(new PrintStream(baos));
    assertThat(baos.toString(), containsString(String.format("" + "1 Scenarios (1 undefined)%n" + "1 Steps (1 undefined)%n")));
}
Also used : PrintStream(java.io.PrintStream) StepDefinitionReporter(cucumber.api.StepDefinitionReporter) Reporter(gherkin.formatter.Reporter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) 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