Is it possible to pass Java-Enum as argument from cucumber feature file Is it possible to pass Java-Enum as argument from cucumber feature file selenium selenium

Is it possible to pass Java-Enum as argument from cucumber feature file


The answer is: Yes

You can use all kind of different types in your scenario: primitive types, own classes (POJOs), enums, ...

Scenario :

Feature: Setup Enum and Print value      In order to manage my Enum      As a System Admin      I want to get the Enum      Scenario: Verify Enum Print      When I supply enum value "GET"

Step definition code :

import cucumber.api.java.en.When;public class EnumTest {    @When("^I supply enum value \"([^\"]*)\"$")    public void i_supply_enum_value(TestEnum arg1) throws Throwable {        testMyEnum(arg1);    }    public enum TestEnum {        GET,        POST,        PATCH    }    protected void testMyEnum(TestEnum testEnumValue) {        switch (testEnumValue) {            case GET:                System.out.println("Enum Value GET");                break;            case POST:                System.out.println("Enum Value POST");                break;            default:                System.out.println("Enum Value PATCH");                break;        }    }}

Let me know how you are doing. I could try to help you.