Search in sources :

Example 31 with Step

use of io.cucumber.core.gherkin.Step in project cucumber-jvm by cucumber.

the class FeatureParserTest method backgrounds_can_occur_twice.

@Test
void backgrounds_can_occur_twice() throws IOException {
    URI uri = URI.create("classpath:com/example.feature");
    String source = new String(readAllBytes(Paths.get("src/test/resources/io/cucumber/core/gherkin/messages/background.feature")));
    Feature feature = parser.parse(uri, source, UUID::randomUUID).get();
    Pickle pickle = feature.getPickles().get(0);
    List<Step> steps = pickle.getSteps();
    assertEquals(3, steps.size());
}
Also used : Pickle(io.cucumber.core.gherkin.Pickle) Step(io.cucumber.core.gherkin.Step) URI(java.net.URI) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 32 with Step

use of io.cucumber.core.gherkin.Step in project cucumber-jvm by cucumber.

the class FeatureParserTest method empty_table_is_parsed.

@Test
void empty_table_is_parsed() throws IOException {
    URI uri = URI.create("classpath:com/example.feature");
    String source = new String(readAllBytes(Paths.get("src/test/resources/io/cucumber/core/gherkin/messages/empty-table.feature")));
    Feature feature = parser.parse(uri, source, UUID::randomUUID).get();
    Pickle pickle = feature.getPickles().get(0);
    Step step = pickle.getSteps().get(0);
    DataTableArgument argument = (DataTableArgument) step.getArgument();
    assertEquals(5, argument.getLine());
}
Also used : Pickle(io.cucumber.core.gherkin.Pickle) DataTableArgument(io.cucumber.core.gherkin.DataTableArgument) Step(io.cucumber.core.gherkin.Step) URI(java.net.URI) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 33 with Step

use of io.cucumber.core.gherkin.Step in project cucumber-jvm by cucumber.

the class FeatureParserTest method empty_doc_string_media_type_is_null.

@Test
void empty_doc_string_media_type_is_null() throws IOException {
    URI uri = URI.create("classpath:com/example.feature");
    String source = new String(readAllBytes(Paths.get("src/test/resources/io/cucumber/core/gherkin/messages/doc-string.feature")));
    Feature feature = parser.parse(uri, source, UUID::randomUUID).get();
    Pickle pickle = feature.getPickles().get(0);
    List<Step> steps = pickle.getSteps();
    assertAll(() -> {
        assertNull(((DocStringArgument) steps.get(0).getArgument()).getContentType());
        assertEquals("text/plain", ((DocStringArgument) steps.get(1).getArgument()).getContentType());
    });
}
Also used : Pickle(io.cucumber.core.gherkin.Pickle) Step(io.cucumber.core.gherkin.Step) URI(java.net.URI) Feature(io.cucumber.core.gherkin.Feature) Test(org.junit.jupiter.api.Test)

Example 34 with Step

use of io.cucumber.core.gherkin.Step 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 35 with Step

use of io.cucumber.core.gherkin.Step 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)

Aggregations

Step (io.cucumber.core.gherkin.Step)37 Test (org.junit.jupiter.api.Test)26 StepDefinition (io.cucumber.core.backend.StepDefinition)22 Feature (io.cucumber.core.gherkin.Feature)22 Argument (io.cucumber.core.stepexpression.Argument)17 StubStepDefinition (io.cucumber.core.backend.StubStepDefinition)15 StepExpression (io.cucumber.core.stepexpression.StepExpression)14 Executable (org.junit.jupiter.api.function.Executable)14 CucumberException (io.cucumber.core.exception.CucumberException)12 URI (java.net.URI)11 SnippetGenerator (io.cucumber.core.snippets.SnippetGenerator)8 ParameterTypeRegistry (io.cucumber.cucumberexpressions.ParameterTypeRegistry)8 CucumberBackendException (io.cucumber.core.backend.CucumberBackendException)5 CucumberInvocationTargetException (io.cucumber.core.backend.CucumberInvocationTargetException)4 DataTableType (io.cucumber.datatable.DataTableType)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 Pickle (io.cucumber.core.gherkin.Pickle)3 ArrayList (java.util.ArrayList)3 Located (io.cucumber.core.backend.Located)2 EventBus (io.cucumber.core.eventbus.EventBus)2