junit Java Cucumber无法识别字符串参数

gfttwv5a  于 2023-10-20  发布在  Java
关注(0)|答案(1)|浏览(137)

Cucumber不识别String参数,我想用它作为货币。它只识别int值。(它会找到这些步骤,因为其他步骤也可以工作)

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

它显示以下错误消息:

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();
}
  • 因为我创建了一个帐户
  • 当我存款100英镑时
  • 那么我的余额是100英镑

有什么问题吗?

lf5gs5x2

lf5gs5x21#

https://cucumber.io/docs/cucumber/cucumber-expressions/
{string}匹配单引号或双引号字符串,例如“banana split”或“banana split”(但不是banana split)。
对于没有引号(也没有空格)的货币代码,您需要{word},因此:

@When("I deposit {int} of {word}")

相关问题