Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass a Boolean parameter in cucumber with java?

Tags:

java

cucumber

How can I pass a Boolean parameter in cucumber with java? I hava the following method with a Boolean parameter:

@Then("test if he is a admin")
public void verify_connect(boolean admin)
{
    if(admin)
        connectAsAdmin();
    else 
        connectAsUser();
}
like image 206
Lamya Messaoudi Avatar asked Mar 04 '23 14:03

Lamya Messaoudi


1 Answers

Use @ParameterType https://cucumber.io/docs/cucumber/cucumber-expressions/

@ParameterType(value = "true|True|TRUE|false|False|FALSE")
public Boolean booleanValue(String value) {
    return Boolean.valueOf(value);
}

@Then("Something is set to {booleanValue}")
public void somethingIsSetTo(Boolean value) {

}
like image 83
albundyszabolcs Avatar answered Mar 13 '23 00:03

albundyszabolcs