Search in sources :

Example 71 with TimeServiceEventBus

use of io.cucumber.core.runtime.TimeServiceEventBus in project cucumber-jvm by cucumber.

the class TeamCityPluginTest method should_print_error_message_for_pending_steps.

@Test
void should_print_error_message_for_pending_steps() {
    Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Given first step\n" + "    Given second step\n");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out))).withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step", new StubPendingException()))).build().run();
    assertThat(out, bytesContainsString("" + "##teamcity[testFailed timestamp = '1970-01-01T12:00:00.000+0000' duration = '0' message = 'Step pending' details = 'TODO: implement me' name = 'first step']"));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) PrintStream(java.io.PrintStream) StubPendingException(io.cucumber.core.backend.StubPendingException) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UUID(java.util.UUID) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 72 with TimeServiceEventBus

use of io.cucumber.core.runtime.TimeServiceEventBus in project cucumber-jvm by cucumber.

the class TeamCityPluginTest method should_handle_attach_events.

@Test
void should_handle_attach_events() {
    Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Given first step\n");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out))).withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(singletonList(new StubHookDefinition((TestCaseState state) -> state.attach("A message", "text/plain", "message.txt"))), singletonList(new StubStepDefinition("first step")), emptyList())).build().run();
    assertThat(out, bytesContainsString("" + "##teamcity[message text='Embed event: message.txt |[text/plain 9 bytes|]|n' status='NORMAL']\n"));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) PrintStream(java.io.PrintStream) StubHookDefinition(io.cucumber.core.backend.StubHookDefinition) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UUID(java.util.UUID) Feature(io.cucumber.core.gherkin.Feature) TestCaseState(io.cucumber.core.backend.TestCaseState) Test(org.junit.jupiter.api.Test)

Example 73 with TimeServiceEventBus

use of io.cucumber.core.runtime.TimeServiceEventBus in project cucumber-jvm by cucumber.

the class TeamCityPluginTest method should_print_error_message_for_failed_steps.

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

Example 74 with TimeServiceEventBus

use of io.cucumber.core.runtime.TimeServiceEventBus in project cucumber-jvm by cucumber.

the class TeamCityPluginTest method should_handle_nameless_attach_events.

@Test
void should_handle_nameless_attach_events() {
    Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Given first step\n");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out))).withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(singletonList(new StubHookDefinition((TestCaseState state) -> state.attach("A message", "text/plain", null))), singletonList(new StubStepDefinition("first step")), emptyList())).build().run();
    assertThat(out, bytesContainsString("" + "##teamcity[message text='Embed event: |[text/plain 9 bytes|]|n' status='NORMAL']\n"));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) PrintStream(java.io.PrintStream) StubHookDefinition(io.cucumber.core.backend.StubHookDefinition) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UUID(java.util.UUID) Feature(io.cucumber.core.gherkin.Feature) TestCaseState(io.cucumber.core.backend.TestCaseState) Test(org.junit.jupiter.api.Test)

Example 75 with TimeServiceEventBus

use of io.cucumber.core.runtime.TimeServiceEventBus in project cucumber-jvm by cucumber.

the class TeamCityPluginTest method should_print_location_hint_for_java_hooks.

@Test
void should_print_location_hint_for_java_hooks() {
    Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + "  Scenario: scenario name\n" + "    Given first step\n");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out))).withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(singletonList(new StubHookDefinition("com.example.HookDefinition.beforeHook()")), singletonList(new StubStepDefinition("first step")), emptyList())).build().run();
    assertThat(out, bytesContainsString("" + "##teamcity[testStarted timestamp = '1970-01-01T12:00:00.000+0000' locationHint = 'java:test://com.example.HookDefinition/beforeHook' captureStandardOutput = 'true' name = 'Before']\n"));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) PrintStream(java.io.PrintStream) StubHookDefinition(io.cucumber.core.backend.StubHookDefinition) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UUID(java.util.UUID) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Aggregations

TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)80 Test (org.junit.jupiter.api.Test)77 UUID (java.util.UUID)63 ByteArrayOutputStream (java.io.ByteArrayOutputStream)59 Feature (io.cucumber.core.gherkin.Feature)55 StubBackendSupplier (io.cucumber.core.runtime.StubBackendSupplier)53 StubFeatureSupplier (io.cucumber.core.runtime.StubFeatureSupplier)52 StubStepDefinition (io.cucumber.core.backend.StubStepDefinition)46 StubHookDefinition (io.cucumber.core.backend.StubHookDefinition)19 StepDurationTimeService (io.cucumber.core.runner.StepDurationTimeService)19 DocString (io.cucumber.docstring.DocString)17 PluginFactory (io.cucumber.core.plugin.PluginFactory)13 Plugins (io.cucumber.core.plugin.Plugins)13 PrintStream (java.io.PrintStream)12 EventBus (io.cucumber.core.eventbus.EventBus)11 RuntimeOptionsBuilder (io.cucumber.core.options.RuntimeOptionsBuilder)6 StubPendingException (io.cucumber.core.backend.StubPendingException)4 TestCaseState (io.cucumber.core.backend.TestCaseState)4 TestFeatureParser (io.cucumber.core.feature.TestFeatureParser)4 DataTable (io.cucumber.datatable.DataTable)4