【问题标题】:Java Cucumber does not recognize my string parameterJava Cucumber 无法识别我的字符串参数
【发布时间】:2019-09-11 00:45:23
【问题描述】:

Cucumber 无法识别我想将其用作货币的字符串参数。它只识别 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 英镑

可能是什么问题?

【问题讨论】:

    标签: java junit cucumber cucumber-java cucumber-junit


    【解决方案1】:

    来自https://cucumber.io/docs/cucumber/cucumber-expressions/

    {string} 匹配单引号或双引号字符串, 例如“香蕉分割”或“香蕉分割”(但不是香蕉分割)。

    对于没有任何引号(也没有任何空格)的货币代码,您需要 {word},所以:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-17
      • 1970-01-01
      • 2017-12-31
      • 1970-01-01
      • 2015-02-17
      • 1970-01-01
      • 2013-11-30
      • 1970-01-01
      相关资源
      最近更新 更多