use*_*543 3 java junit cucumber cucumber-junit cucumber-java
Cucumber 无法识别 String 参数,我想将其用作货币。它只识别 int 值。(它找到步骤,因为其他步骤有效)
@When("I deposit {int} of {string}")
public void testDeposit(int value, String currency) throws ClientProtocolException, IOException {
Run Code Online (Sandbox Code Playgroud)
它显示以下错误消息:
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();
}
Run Code Online (Sandbox Code Playgroud)
可能是什么问题?
来自https://cucumber.io/docs/cucumber/cucumber-expressions/
{string} 匹配单引号或双引号字符串,例如 "banana split" 或 'banana split'(但不是香蕉拆分)。
对于没有任何引号(也没有任何空格)的货币代码,您需要 {word},因此:
@When("I deposit {int} of {word}")
Run Code Online (Sandbox Code Playgroud)