use of io.cucumber.core.backend.StubStepDefinition in project cucumber-jvm by cucumber.
the class RuntimeTest method should_call_formatter_for_two_scenarios_with_background.
@Test
void should_call_formatter_for_two_scenarios_with_background() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + " Background: background\n" + " Given first step\n" + " Scenario: scenario_1 name\n" + " When second step\n" + " Then third step\n" + " Scenario: scenario_2 name\n" + " Then second step\n");
FormatterSpy formatterSpy = new FormatterSpy();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(formatterSpy).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step"), new StubStepDefinition("second step"), new StubStepDefinition("third step"))).build().run();
assertThat(formatterSpy.toString(), is(equalTo("" + "TestRun started\n" + " TestCase started\n" + " TestStep started\n" + " TestStep finished\n" + " TestStep started\n" + " TestStep finished\n" + " TestStep started\n" + " TestStep finished\n" + " TestCase finished\n" + " TestCase started\n" + " TestStep started\n" + " TestStep finished\n" + " TestStep started\n" + " TestStep finished\n" + " TestCase finished\n" + "TestRun finished\n")));
}
use of io.cucumber.core.backend.StubStepDefinition in project cucumber-jvm by cucumber.
the class StepExpressionFactoryTest method creates_a_step_expression.
@Test
void creates_a_step_expression() {
StepDefinition stepDefinition = new StubStepDefinition("Given a step");
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
assertThat(expression.getSource(), is("Given a step"));
assertThat(expression.getExpressionType(), is(CucumberExpression.class));
assertThat(expression.match("Given a step"), is(emptyList()));
}
use of io.cucumber.core.backend.StubStepDefinition in project cucumber-jvm by cucumber.
the class StepExpressionFactoryTest method empty_table_cells_are_presented_as_null_to_transformer.
@SuppressWarnings("unchecked")
@Test
void empty_table_cells_are_presented_as_null_to_transformer() {
registry.setDefaultDataTableEntryTransformer((map, valueType, tableCellByTypeTransformer) -> objectMapper.convertValue(map, objectMapper.constructType(valueType)));
StepDefinition stepDefinition = new StubStepDefinition("Given some stuff:", getTypeFromStepDefinition());
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
List<List<String>> table = asList(asList("name", "amount", "unit"), asList("chocolate", null, "tbsp"));
List<Argument> match = expression.match("Given some stuff:", table);
List<Ingredient> ingredients = (List<Ingredient>) match.get(0).getValue();
Ingredient ingredient = ingredients.get(0);
assertThat(ingredient.name, is(equalTo("chocolate")));
}
use of io.cucumber.core.backend.StubStepDefinition in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_print_output_from_after_hooks.
@Test
void should_print_output_from_after_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 PrettyFormatter(out)).withRuntimeOptions(new RuntimeOptionsBuilder().setMonochrome().build()).withBackendSupplier(new StubBackendSupplier(emptyList(), singletonList(new StubStepDefinition("first step", "path/step_definitions.java:3")), singletonList(new StubHookDefinition(testCaseState -> testCaseState.log("printed from hook"))))).build().run();
assertThat(out, bytesContainsString("" + " Given first step # path/step_definitions.java:3\n" + "\n" + " printed from hook\n"));
}
use of io.cucumber.core.backend.StubStepDefinition in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_handle_background.
@Test
void should_handle_background() {
Feature feature = TestFeatureParser.parse("path/test.feature", "" + "Feature: feature name\n" + " Background: background name\n" + " Given first step\n" + " Scenario: s1\n" + " Then second step\n" + " Scenario: s2\n" + " Then third step\n");
ByteArrayOutputStream out = new ByteArrayOutputStream();
Runtime.builder().withFeatureSupplier(new StubFeatureSupplier(feature)).withAdditionalPlugins(new PrettyFormatter(out)).withRuntimeOptions(new RuntimeOptionsBuilder().setMonochrome().build()).withBackendSupplier(new StubBackendSupplier(new StubStepDefinition("first step", "path/step_definitions.java:3"), new StubStepDefinition("second step", "path/step_definitions.java:7"), new StubStepDefinition("third step", "path/step_definitions.java:11"))).build().run();
assertThat(out, bytesContainsString("" + "\n" + "Scenario: s1 # path/test.feature:4\n" + " Given first step # path/step_definitions.java:3\n" + " Then second step # path/step_definitions.java:7\n" + "\n" + "Scenario: s2 # path/test.feature:6\n" + " Given first step # path/step_definitions.java:3\n" + " Then third step # path/step_definitions.java:11\n"));
}
Aggregations