Search in sources :

Example 76 with StubFeatureSupplier

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

the class TimelineFormatterTest method runFormatterWithPlugin.

private void runFormatterWithPlugin() {
    StepDurationTimeService timeService = new StepDurationTimeService(Duration.ofMillis(1000));
    Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(failingFeature, successfulFeature, pendingFeature)).withAdditionalPlugins(timeService).withEventBus(new TimeServiceEventBus(timeService, UUID::randomUUID)).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("bg_1"), new StubStepDefinition("bg_2"), new StubStepDefinition("bg_3"), new StubStepDefinition("step_01"), new StubStepDefinition("step_02"), new StubStepDefinition("step_03", new StubException()), new StubStepDefinition("step_10"), new StubStepDefinition("step_20"), new StubStepDefinition("step_30"))).withRuntimeOptions(runtimeOptionsBuilder.build()).build().run();
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) StubBackendSupplier(io.cucumber.core.runtime.StubBackendSupplier) StubFeatureSupplier(io.cucumber.core.runtime.StubFeatureSupplier) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) StepDurationTimeService(io.cucumber.core.runner.StepDurationTimeService)

Example 77 with StubFeatureSupplier

use of io.cucumber.core.runtime.StubFeatureSupplier 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)

Example 78 with StubFeatureSupplier

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

the class TeamCityPluginTest method should_print_error_message_for_undefined_steps.

@Test
void should_print_error_message_for_undefined_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()).build().run();
    assertThat(out, bytesContainsString("" + "##teamcity[testFailed timestamp = '1970-01-01T12:00:00.000+0000' duration = '0' message = 'Step undefined' details = 'You can implement this step and 1 other step(s) using the snippet(s) below:|n|ntest snippet 0|ntest snippet 1|n' 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) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UUID(java.util.UUID) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Aggregations

StubBackendSupplier (io.cucumber.core.runtime.StubBackendSupplier)78 StubFeatureSupplier (io.cucumber.core.runtime.StubFeatureSupplier)78 Feature (io.cucumber.core.gherkin.Feature)77 ByteArrayOutputStream (java.io.ByteArrayOutputStream)77 Test (org.junit.jupiter.api.Test)77 StubStepDefinition (io.cucumber.core.backend.StubStepDefinition)70 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)55 UUID (java.util.UUID)53 StubHookDefinition (io.cucumber.core.backend.StubHookDefinition)25 StepDurationTimeService (io.cucumber.core.runner.StepDurationTimeService)18 DocString (io.cucumber.docstring.DocString)17 RuntimeOptionsBuilder (io.cucumber.core.options.RuntimeOptionsBuilder)16 PrintStream (java.io.PrintStream)11 TestFeatureParser (io.cucumber.core.feature.TestFeatureParser)6 Runtime (io.cucumber.core.runtime.Runtime)6 DataTable (io.cucumber.datatable.DataTable)6 Arrays.asList (java.util.Arrays.asList)6 Collections.emptyList (java.util.Collections.emptyList)6 Collections.singletonList (java.util.Collections.singletonList)6 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)6