Search in sources :

Example 6 with SnippetGenerator

use of io.cucumber.core.snippets.SnippetGenerator in project cucumber-jvm by cucumber.

the class JavaSnippetTest method snippetForDataTable.

private String snippetForDataTable(String stepText) {
    Step step = createStepWithDataTable(stepText);
    List<String> snippet = new SnippetGenerator(new JavaSnippet(), new ParameterTypeRegistry(Locale.ENGLISH)).getSnippet(step, snippetType);
    return String.join("\n", snippet);
}
Also used : SnippetGenerator(io.cucumber.core.snippets.SnippetGenerator) ParameterTypeRegistry(io.cucumber.cucumberexpressions.ParameterTypeRegistry) Step(io.cucumber.core.gherkin.Step)

Example 7 with SnippetGenerator

use of io.cucumber.core.snippets.SnippetGenerator in project cucumber-jvm by cucumber.

the class JavaSnippetTest method snippetForWhenAnd.

private String snippetForWhenAnd(String stepText) {
    String source = "" + "Feature: Test feature\n" + "  Scenario: Test Scenario\n" + "    When some other step\n" + "    And " + stepText + "\n";
    Feature feature = TestFeatureParser.parse(source);
    Step step = feature.getPickles().get(0).getSteps().get(1);
    List<String> snippet = new SnippetGenerator(new JavaSnippet(), new ParameterTypeRegistry(Locale.ENGLISH)).getSnippet(step, snippetType);
    return String.join("\n", snippet);
}
Also used : SnippetGenerator(io.cucumber.core.snippets.SnippetGenerator) ParameterTypeRegistry(io.cucumber.cucumberexpressions.ParameterTypeRegistry) Step(io.cucumber.core.gherkin.Step) Feature(io.cucumber.core.gherkin.Feature)

Example 8 with SnippetGenerator

use of io.cucumber.core.snippets.SnippetGenerator in project cucumber-jvm by cucumber.

the class JavaSnippetTest method snippetFor.

private String snippetFor(String stepText, ParameterType<?> parameterType) {
    Step step = createStep(stepText);
    ParameterTypeRegistry parameterTypeRegistry = new ParameterTypeRegistry(Locale.ENGLISH);
    parameterTypeRegistry.defineParameterType(parameterType);
    List<String> snippet = new SnippetGenerator(new JavaSnippet(), parameterTypeRegistry).getSnippet(step, snippetType);
    return String.join("\n", snippet);
}
Also used : ParameterTypeRegistry(io.cucumber.cucumberexpressions.ParameterTypeRegistry) SnippetGenerator(io.cucumber.core.snippets.SnippetGenerator) Step(io.cucumber.core.gherkin.Step)

Example 9 with SnippetGenerator

use of io.cucumber.core.snippets.SnippetGenerator in project cucumber-jvm by cucumber.

the class JavaSnippetTest method snippetForWildCard.

private String snippetForWildCard(String stepText) {
    String source = "" + "Feature: Test feature\n" + "  Scenario: Test Scenario\n" + "    * " + stepText + "\n";
    Feature feature = TestFeatureParser.parse(source);
    Step step = feature.getPickles().get(0).getSteps().get(0);
    List<String> snippet = new SnippetGenerator(new JavaSnippet(), new ParameterTypeRegistry(Locale.ENGLISH)).getSnippet(step, snippetType);
    return String.join("\n", snippet);
}
Also used : SnippetGenerator(io.cucumber.core.snippets.SnippetGenerator) ParameterTypeRegistry(io.cucumber.cucumberexpressions.ParameterTypeRegistry) Step(io.cucumber.core.gherkin.Step) Feature(io.cucumber.core.gherkin.Feature)

Aggregations

SnippetGenerator (io.cucumber.core.snippets.SnippetGenerator)9 Step (io.cucumber.core.gherkin.Step)8 ParameterTypeRegistry (io.cucumber.cucumberexpressions.ParameterTypeRegistry)8 Feature (io.cucumber.core.gherkin.Feature)2 ArrayList (java.util.ArrayList)1