use of io.cucumber.core.backend.StepDefinition in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_mark_nested_arguments_as_part_of_enclosing_argument.
@Test
void should_mark_nested_arguments_as_part_of_enclosing_argument() {
Formats formats = ansi();
PrettyFormatter prettyFormatter = new PrettyFormatter(new ByteArrayOutputStream());
StepTypeRegistry registry = new StepTypeRegistry(Locale.ENGLISH);
StepExpressionFactory stepExpressionFactory = new StepExpressionFactory(registry, bus);
StepDefinition stepDefinition = new StubStepDefinition("^the order is placed( and (not( yet)? )?confirmed)?$", String.class);
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
String stepText = "the order is placed and not yet confirmed";
String formattedText = prettyFormatter.formatStepText("Given ", stepText, formats.get("passed"), formats.get("passed_arg"), createArguments(expression.match(stepText)));
assertThat(formattedText, equalTo(AnsiEscapes.GREEN + "Given " + AnsiEscapes.RESET + AnsiEscapes.GREEN + "the order is placed" + AnsiEscapes.RESET + AnsiEscapes.GREEN + AnsiEscapes.INTENSITY_BOLD + " and not yet confirmed" + AnsiEscapes.RESET));
}
use of io.cucumber.core.backend.StepDefinition in project cucumber-jvm by cucumber.
the class CachingGlueTest method returns_null_if_no_matching_steps_found.
@Test
void returns_null_if_no_matching_steps_found() throws AmbiguousStepDefinitionsException {
StepDefinition stepDefinition = new MockedStepDefinition("pattern1");
glue.addStepDefinition(stepDefinition);
URI uri = URI.create("file:path/to.feature");
Step pickleStep = getPickleStep("pattern");
assertThat(glue.stepDefinitionMatch(uri, pickleStep), is(nullValue()));
}
use of io.cucumber.core.backend.StepDefinition in project cucumber-jvm by cucumber.
the class DuplicateStepDefinitionExceptionTest method can_report_duplicate_step_definitions.
@Test
void can_report_duplicate_step_definitions() {
final StepDefinition mockStepDefinitionA = mock(StepDefinition.class);
when(mockStepDefinitionA.getLocation()).thenReturn("StepDefinitionA_Location");
final StepDefinition mockStepDefinitionB = mock(StepDefinition.class);
when(mockStepDefinitionB.getLocation()).thenReturn("StepDefinitionB_Location");
DuplicateStepDefinitionException expectedThrown = new DuplicateStepDefinitionException(mockStepDefinitionA, mockStepDefinitionB);
assertAll(() -> assertThat(expectedThrown.getMessage(), is(equalTo("Duplicate step definitions in StepDefinitionA_Location and StepDefinitionB_Location"))), () -> assertThat(expectedThrown.getCause(), is(nullValue())));
}
Aggregations