sgr*_*lon 3 java cucumber gherkin
我想要相同的小黄瓜句子(带参数和不带参数):
带参数的小黄瓜:
When a 'notify' message is sent to the green box with the properties.
|type|message|
|error|The error message|
Run Code Online (Sandbox Code Playgroud)
没有参数的小黄瓜:
When a 'notify' message is sent to the green box with the properties.
Run Code Online (Sandbox Code Playgroud)
爪哇(黄瓜):
@When("^a '(.*)' message is sent to the green box with the properties.$")
public void hello(String name, List<GherkinCondition> conditions) {
...
}
Run Code Online (Sandbox Code Playgroud)
我有一个错误,因为 java 方法是用 2 个参数声明的,在“没有参数”的情况下,我只有一个。
堆栈跟踪:
cucumber.runtime.CucumberException: Arity mismatch: Step Definition 'steps.CommonSteps.hello(String,GherkinCondition>) in file:/C:/workspace/xxxxx/java/target/classes/' with pattern [^a '(.*)' message is sent to the green box with the properties.$] is declared with 2 parameters. However, the gherkin step has 1 arguments [notify].
Run Code Online (Sandbox Code Playgroud)
Cucumber 步骤定义不支持可选参数。
您可以编写两个不同的步骤定义,也可以为第二种情况提供一个空的数据表。
When a 'notify' message is sent to the green box with the properties.
|type|message|
Run Code Online (Sandbox Code Playgroud)
甚至
When a 'notify' message is sent to the green box with the properties.
|||
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11980 次 |
| 最近记录: |