Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Cucumber does not recognize my string parameter

Cucumber doesn't recognize the String parameter what I would like to use it as currency. It only recognise int value. (It finds the steps because other steps works)

@When("I deposit {int} of {string}")
public void testDeposit(int value, String currency) throws ClientProtocolException, IOException {

It shows the following error message:

There were undefined steps. You can implement missing steps with the snippets below:

@When("I deposit {int} of GBP")
public void i_deposit_of_GBP(Integer int1) {
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
}

@Then("My balance is {int} of GBP")
public void my_balance_is_of_GBP(Integer int1) {
    // Write code here that turns the phrase above into concrete actions
    throw new cucumber.api.PendingException();
}
  • Given I created an account
  • When I deposit 100 of GBP
  • Then My balance is 100 of GBP

What can be the problem?

like image 633
user2695543 Avatar asked Jul 18 '26 22:07

user2695543


1 Answers

From https://cucumber.io/docs/cucumber/cucumber-expressions/

{string} Matches single-quoted or double-quoted strings, for example "banana split" or 'banana split' (but not banana split).

For your currency code that does not have any quotes (nor any spaces), you want {word}, so:

 @When("I deposit {int} of {word}")
like image 143
racraman Avatar answered Jul 21 '26 10:07

racraman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!