Search in sources :

Example 1 with SnippetGenerator

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

the class Runner method generateSnippetsForStep.

private List<String> generateSnippetsForStep(Step step) {
    List<String> snippets = new ArrayList<>();
    for (SnippetGenerator snippetGenerator : snippetGenerators) {
        List<String> snippet = snippetGenerator.getSnippet(step, runnerOptions.getSnippetType());
        snippets.addAll(snippet);
    }
    return snippets;
}
Also used : SnippetGenerator(io.cucumber.core.snippets.SnippetGenerator) ArrayList(java.util.ArrayList)

Example 2 with SnippetGenerator

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

the class JavaSnippetTest method snippetForDocString.

private String snippetForDocString(String stepText, String docString, ParameterType<String> parameterType) {
    Step step = createStepWithDocString(stepText, docString);
    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 3 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, ParameterType<String> parameterType) {
    Step step = createStepWithDataTable(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 4 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) {
    Step step = createStep(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 5 with SnippetGenerator

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

the class JavaSnippetTest method snippetForDocString.

private String snippetForDocString(String stepText, String docString) {
    Step step = createStepWithDocString(stepText, docString);
    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)

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