javajunitcucumbercucumber-javacucumber-junit

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();
}

What can be the problem?


Solution

  • 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}")