Hello,
I’m using cucumber expressions snd am struggling getting the basics working. I am not sure if I am doing it right as there was a little confusion around just providing the expression class like regular glue code (and it seems so simple!). Perhaps some can shed some light.
With this Gherkin:
Given a customer has a savings account
Given a customer has a checking account
And this step:
@Given("a customer has a {account_type} account")
public void a_customer_has_a_account(AccountType account_type) {
System.out.println("Has an account type: " + account_type);
}
And this entry in config\cucumber.yml:
typeRegistry.defineParameterType(new ParameterType<>(
"account_type", // name
"savings|checking", // regexp
AccountType.class, // type
AccountType::new // transformer function
))
With this inner-class in the steps file:
public class AccountType {
String accountType;
AccountType(String accountType) {
this.accountType = accountType;
}
}
I get this:
Exception in thread "main" cucumber.runtime.CucumberException: Could not create a cucumber expression for 'a customer has a {account_type} account'.
It appears you did not register parameter type. The details are in the stacktrace below.
You can find the documentation here: https://docs.cucumber.io/cucumber/cucumber-
expressions/
at io.cucumber.stepexpression.StepExpressionFactory.registerTypeInConfiguration(StepExpressionFactory.java:87)
at io.cucumber.stepexpression.StepExpressionFactory.createExpression(StepExpressionFactory.java:65)
at io.cucumber.stepexpression.StepExpressionFactory.createExpression(StepExpressionFactory.java:54)
--
TimHello,
I’m using cucumber expressions snd am struggling getting the basics working. I am not sure if I am doing it right as there was a little confusion around just providing the expression class like regular glue code (and it seems so simple!). Perhaps some can shed some light.
With this Gherkin:
Given a customer has a savings account
Given a customer has a checking account
And this step:
@Given("a customer has a {account_type} account")
public void a_customer_has_a_account(AccountType account_type) {
System.out.println("Has an account type: " + account_type);
}
And this entry in config\cucumber.yml:
Halfordian Golfer wrote:Hello,
I’m using cucumber expressions snd am struggling getting the basics working. I am not sure if I am doing it right as there was a little confusion around just providing the expression class like regular glue code (and it seems so simple!). Perhaps some can shed some light.
With this Gherkin:
Given a customer has a savings account
Given a customer has a checking account
And this step:
@Given("a customer has a {account_type} account")
public void a_customer_has_a_account(AccountType account_type) {
System.out.println("Has an account type: " + account_type);
}
And this entry in config\cucumber.yml:
Cucumber-JVM does not use cucumber.yml. The java-calculator example uses ParameterTypes.java to define parameter types.
/BjörntypeRegistry.defineParameterType(new ParameterType<>(
"account_type", // name
"savings|checking", // regexp
AccountType.class, // type
AccountType::new // transformer function
))
With this inner-class in the steps file:
public class AccountType {
String accountType;
AccountType(String accountType) {
this.accountType = accountType;
}
}
I get this:
Exception in thread "main" cucumber.runtime.CucumberException: Could not create a cucumber expression for 'a customer has a {account_type} account'.
It appears you did not register parameter type. The details are in the stacktrace below.
You can find the documentation here: https://docs.cucumber.io/cucumber/cucumber-
expressions/
at io.cucumber.stepexpression.StepExpressionFactory.registerTypeInConfiguration(StepExpressionFactory.java:87)
at io.cucumber.stepexpression.StepExpressionFactory.createExpression(StepExpressionFactory.java:65)
at io.cucumber.stepexpression.StepExpressionFactory.createExpression(StepExpressionFactory.java:54)
--
Tim
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.