Search in sources :

Example 1 with StepTypeRegistry

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));
}
Also used : StepTypeRegistry(io.cucumber.core.stepexpression.StepTypeRegistry) StepExpressionFactory(io.cucumber.core.stepexpression.StepExpressionFactory) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) StepDefinition(io.cucumber.core.backend.StepDefinition) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BytesContainsString.bytesContainsString(io.cucumber.core.plugin.BytesContainsString.bytesContainsString) StepExpression(io.cucumber.core.stepexpression.StepExpression) Test(org.junit.jupiter.api.Test)

Example 2 with StepTypeRegistry

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));
}
Also used : StepTypeRegistry(io.cucumber.core.stepexpression.StepTypeRegistry) StepExpressionFactory(io.cucumber.core.stepexpression.StepExpressionFactory) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) StepDefinition(io.cucumber.core.backend.StepDefinition) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BytesContainsString.bytesContainsString(io.cucumber.core.plugin.BytesContainsString.bytesContainsString) StepExpression(io.cucumber.core.stepexpression.StepExpression) Test(org.junit.jupiter.api.Test)

Example 3 with StepTypeRegistry

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);
}
Also used : Locale(java.util.Locale) StepTypeRegistry(io.cucumber.core.stepexpression.StepTypeRegistry)

Example 4 with StepTypeRegistry

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();
    }
}
Also used : StepTypeRegistry(io.cucumber.core.stepexpression.StepTypeRegistry)

Example 5 with StepTypeRegistry

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));
}
Also used : StepTypeRegistry(io.cucumber.core.stepexpression.StepTypeRegistry) StepExpressionFactory(io.cucumber.core.stepexpression.StepExpressionFactory) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) StepDefinition(io.cucumber.core.backend.StepDefinition) StubStepDefinition(io.cucumber.core.backend.StubStepDefinition) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BytesContainsString.bytesContainsString(io.cucumber.core.plugin.BytesContainsString.bytesContainsString) StepExpression(io.cucumber.core.stepexpression.StepExpression) Test(org.junit.jupiter.api.Test)

Aggregations

StepTypeRegistry (io.cucumber.core.stepexpression.StepTypeRegistry)6 StepDefinition (io.cucumber.core.backend.StepDefinition)4 Test (org.junit.jupiter.api.Test)4 StubStepDefinition (io.cucumber.core.backend.StubStepDefinition)3 BytesContainsString.bytesContainsString (io.cucumber.core.plugin.BytesContainsString.bytesContainsString)3 StepExpression (io.cucumber.core.stepexpression.StepExpression)3 StepExpressionFactory (io.cucumber.core.stepexpression.StepExpressionFactory)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 DataTableTypeDefinition (io.cucumber.core.backend.DataTableTypeDefinition)1 DefaultDataTableCellTransformerDefinition (io.cucumber.core.backend.DefaultDataTableCellTransformerDefinition)1 DefaultDataTableEntryTransformerDefinition (io.cucumber.core.backend.DefaultDataTableEntryTransformerDefinition)1 DefaultParameterTransformerDefinition (io.cucumber.core.backend.DefaultParameterTransformerDefinition)1 DocStringTypeDefinition (io.cucumber.core.backend.DocStringTypeDefinition)1 HookDefinition (io.cucumber.core.backend.HookDefinition)1 ParameterTypeDefinition (io.cucumber.core.backend.ParameterTypeDefinition)1 ScenarioScoped (io.cucumber.core.backend.ScenarioScoped)1 SourceReference (io.cucumber.core.backend.SourceReference)1 TestCaseState (io.cucumber.core.backend.TestCaseState)1 EventBus (io.cucumber.core.eventbus.EventBus)1 TestFeatureParser (io.cucumber.core.feature.TestFeatureParser)1