Search in sources :

Example 1 with Java8StepDefinition

use of cucumber.runtime.java.Java8StepDefinition in project cucumber-jvm by cucumber.

the class Java8StepDefinitionTest method should_pass_for_param_with_generic_list.

@Test
public void should_pass_for_param_with_generic_list() throws Exception {
    try {
        StepdefBody body = (StepdefBody.A1<List<String>>) p1 -> {
        };
        new Java8StepDefinition(Pattern.compile("^I have (\\d) some step (.*)$"), 0, body, typeIntrospector);
    } catch (CucumberException expected) {
        assertEquals("Can't use java.util.List in lambda step definition. Declare a DataTable argument instead and convert manually with asList/asLists/asMap/asMaps", expected.getMessage());
    }
}
Also used : Java8StepDefinition(cucumber.runtime.java.Java8StepDefinition) CucumberException(cucumber.runtime.CucumberException) StepdefBody(cucumber.api.java8.StepdefBody) Test(org.junit.Test)

Example 2 with Java8StepDefinition

use of cucumber.runtime.java.Java8StepDefinition in project cucumber-jvm by cucumber.

the class Java8StepDefinitionTest method should_calculate_parameters_count_from_body_with_one_param.

@Test
public void should_calculate_parameters_count_from_body_with_one_param() throws Exception {
    StepdefBody body = (StepdefBody.A1<String>) p1 -> {
    };
    Java8StepDefinition def = new Java8StepDefinition(Pattern.compile("^I have (\\d) some step (.*)$"), 0, body, typeIntrospector);
    assertEquals(new Integer(1), def.getParameterCount());
}
Also used : Java8StepDefinition(cucumber.runtime.java.Java8StepDefinition) StepdefBody(cucumber.api.java8.StepdefBody) Test(org.junit.Test)

Example 3 with Java8StepDefinition

use of cucumber.runtime.java.Java8StepDefinition in project cucumber-jvm by cucumber.

the class Java8StepDefinitionTest method should_fail_for_param_with_non_generic_list.

@Test
public void should_fail_for_param_with_non_generic_list() throws Exception {
    try {
        StepdefBody body = (StepdefBody.A1<List>) p1 -> {
        };
        new Java8StepDefinition(Pattern.compile("^I have (\\d) some step (.*)$"), 0, body, typeIntrospector);
    } catch (CucumberException expected) {
        assertEquals("Can't use java.util.List in lambda step definition. Declare a DataTable argument instead and convert manually with asList/asLists/asMap/asMaps", expected.getMessage());
    }
}
Also used : Java8StepDefinition(cucumber.runtime.java.Java8StepDefinition) CucumberException(cucumber.runtime.CucumberException) StepdefBody(cucumber.api.java8.StepdefBody) Test(org.junit.Test)

Example 4 with Java8StepDefinition

use of cucumber.runtime.java.Java8StepDefinition in project cucumber-jvm by cucumber.

the class Java8StepDefinitionTest method should_calculate_parameters_count_from_body_with_two_params.

@Test
public void should_calculate_parameters_count_from_body_with_two_params() throws Exception {
    StepdefBody body = (StepdefBody.A2<String, String>) (p1, p2) -> {
    };
    Java8StepDefinition def = new Java8StepDefinition(Pattern.compile("^I have some step $"), 0, body, typeIntrospector);
    assertEquals(new Integer(2), def.getParameterCount());
}
Also used : Java8StepDefinition(cucumber.runtime.java.Java8StepDefinition) StepdefBody(cucumber.api.java8.StepdefBody) Test(org.junit.Test)

Aggregations

StepdefBody (cucumber.api.java8.StepdefBody)4 Java8StepDefinition (cucumber.runtime.java.Java8StepDefinition)4 Test (org.junit.Test)4 CucumberException (cucumber.runtime.CucumberException)2