use of io.cucumber.core.stepexpression.StepTypeRegistry in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_mark_nested_argument_as_part_of_full_argument.
@Test
void should_mark_nested_argument_as_part_of_full_argument() {
Formats formats = ansi();
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);
PrettyFormatter prettyFormatter = new PrettyFormatter(new ByteArrayOutputStream());
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.stepexpression.StepTypeRegistry in project cucumber-jvm by cucumber.
the class PrettyFormatterTest method should_mark_subsequent_arguments_in_steps.
@Test
void should_mark_subsequent_arguments_in_steps() {
Formats formats = ansi();
StepTypeRegistry registry = new StepTypeRegistry(Locale.ENGLISH);
StepExpressionFactory stepExpressionFactory = new StepExpressionFactory(registry, bus);
StepDefinition stepDefinition = new StubStepDefinition("text {string} text {string}", String.class);
StepExpression expression = stepExpressionFactory.createExpression(stepDefinition);
PrettyFormatter prettyFormatter = new PrettyFormatter(new ByteArrayOutputStream());
String stepText = "text 'arg1' text 'arg2'";
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 + "text " + AnsiEscapes.RESET + AnsiEscapes.GREEN + AnsiEscapes.INTENSITY_BOLD + "'arg1'" + AnsiEscapes.RESET + AnsiEscapes.GREEN + " text " + AnsiEscapes.RESET + AnsiEscapes.GREEN + AnsiEscapes.INTENSITY_BOLD + "'arg2'" + AnsiEscapes.RESET));
}
use of io.cucumber.core.stepexpression.StepTypeRegistry in project cucumber-jvm by cucumber.
the class Runner method createTypeRegistryForPickle.
private StepTypeRegistry createTypeRegistryForPickle(Pickle pickle) {
String language = pickle.getLanguage();
Locale locale = new Locale(language);
return new StepTypeRegistry(locale);
}
use of io.cucumber.core.stepexpression.StepTypeRegistry in project cucumber-jvm by cucumber.
the class Runner method runPickle.
public void runPickle(Pickle pickle) {
try {
StepTypeRegistry stepTypeRegistry = createTypeRegistryForPickle(pickle);
snippetGenerators = createSnippetGeneratorsForPickle(stepTypeRegistry);
// Java8 step definitions will be added to the glue here
buildBackendWorlds();
glue.prepareGlue(stepTypeRegistry);
TestCase testCase = createTestCaseForPickle(pickle);
testCase.run(bus);
} finally {
glue.removeScenarioScopedGlue();
disposeBackendWorlds();
}
}
use of io.cucumber.core.stepexpression.StepTypeRegistry 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));
}
Aggregations