Java Cucumber does not recognize my string parameter
Asked Answered
S

1

7

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?

Superaltar answered 11/9, 2019 at 0:45 Comment(0)
A
13

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}")
Appreciation answered 11/9, 2019 at 1:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.