use of io.cucumber.core.backend.TestCaseState in project cucumber-jvm by cucumber.
the class TeamCityPluginTest method should_handle_write_events.
@Test
void should_handle_write_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.log("A message"))), singletonList(new StubStepDefinition("first step")), emptyList())).build().run();
assertThat(out, bytesContainsString("" + "##teamcity[message text='Write event:|nA message|n' status='NORMAL']\n"));
}
use of io.cucumber.core.backend.TestCaseState in project cucumber-jvm by cucumber.
the class RuntimeTest method should_make_scenario_name_available_to_hooks.
@Test
void should_make_scenario_name_available_to_hooks() {
final Feature feature = TestFeatureParser.parse("path/test.feature", "Feature: feature name\n" + " Scenario: scenario name\n" + " Given first step\n" + " When second step\n" + " Then third step\n");
final HookDefinition beforeHook = mock(HookDefinition.class);
when(beforeHook.getLocation()).thenReturn("");
when(beforeHook.getTagExpression()).thenReturn("");
FeatureSupplier featureSupplier = new StubFeatureSupplier(feature);
Runtime runtime = Runtime.builder().withFeatureSupplier(featureSupplier).withBackendSupplier(new StubBackendSupplier(singletonList(beforeHook), asList(new StubStepDefinition("first step"), new StubStepDefinition("second step"), new StubStepDefinition("third step")), emptyList())).build();
runtime.run();
ArgumentCaptor<TestCaseState> capturedScenario = ArgumentCaptor.forClass(TestCaseState.class);
verify(beforeHook).execute(capturedScenario.capture());
assertThat(capturedScenario.getValue().getName(), is(equalTo("scenario name")));
}
use of io.cucumber.core.backend.TestCaseState 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"));
}
use of io.cucumber.core.backend.TestCaseState 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"));
}
Aggregations