Search in sources :

Example 1 with StubStaticHookDefinition

use of io.cucumber.core.backend.StubStaticHookDefinition in project cucumber-jvm by cucumber.

the class PrettyFormatterTest method should_print_system_failure_for_failed_hooks.

@Test
void should_print_system_failure_for_failed_hooks() {
    Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Given first step\n");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    assertThrows(StubException.class, () -> Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new PrettyFormatter(out)).withBackendSupplier(new StubBackendSupplier(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), singletonList(new StubStaticHookDefinition(new StubException("Hook failed", "the stack trace"))))).build().run());
    assertThat(out, bytesContainsString("" + "      " + AnsiEscapes.RED + "the stack trace" + AnsiEscapes.RESET + "\n"));
}
Also used : StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) StubStaticHookDefinition(io.cucumber.core.backend.StubStaticHookDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 2 with StubStaticHookDefinition

use of io.cucumber.core.backend.StubStaticHookDefinition in project cucumber-jvm by cucumber.

the class TeamCityPluginTest method should_print_system_failure_for_failed_hooks.

@Test
void should_print_system_failure_for_failed_hooks() {
    Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Given first step\n");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    assertThrows(StubException.class, () -> Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out))).withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), singletonList(new StubStaticHookDefinition(new StubException("Hook failed", "the stack trace"))))).build().run());
    assertThat(out, bytesContainsString("" + "##teamcity[testStarted timestamp = '1970-01-01T12:00:00.000+0000' name = 'Before All/After All']\n" + "##teamcity[testFailed timestamp = '1970-01-01T12:00:00.000+0000' message = 'Before All/After All failed' details = 'the stack trace' name = 'Before All/After All']\n" + "##teamcity[testFinished timestamp = '1970-01-01T12:00:00.000+0000' name = 'Before All/After All']"));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) PrintStream(java.io.PrintStream) StubStaticHookDefinition(io.cucumber.core.backend.StubStaticHookDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Aggregations

StubStaticHookDefinition (io.cucumber.core.backend.StubStaticHookDefinition)2 Feature (io.cucumber.core.gherkin.Feature)2 StubBackendSupplier (io.cucumber.core.runtime.StubBackendSupplier)2 StubFeatureSupplier (io.cucumber.core.runtime.StubFeatureSupplier)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Test (org.junit.jupiter.api.Test)2 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)1 PrintStream (java.io.PrintStream)1