0

我正在尝试用 Cucumber 进行测试。我需要两个步骤中的相同值

不起作用

Scenario Outline: print to screen 
Then print a <filename> to screen
Then print again the <filename> and extension <extension> to screen
Examples:
      | filename| extension |
      | abcd    | txt  |

我得到的错误:

io.cucumber.core.exception.CucumberException: Step [A] is defined with 1 parameters at xxxxxx(java.lang.String)'.
However, the gherkin step has 0 arguments.

基本上说我必须在第一步中至少有一个参数..

有效

Scenario Outline: print to screen
Then print a <filename> to screen
Examples:
      | filename |
      | abcd  |
Then print again the <filename> and extension <extension> to screen
Examples:
      | filename | extension |
      | abcd     | txt  |

以下是步骤定义:


@Then("print a (.*) to screen")
public void printToScreen(String value) {
...
}


@Then("^print again the (.*) and extension (.*) to screen")
public void printToScreenWithExt(String value, String ext) {
...
}

我遵循了这个例子: https ://www.baeldung.com/cucumber-scenario-outline#rewriting-features-using-scenario-outlines

谢谢..

4

1 回答 1

0

好吧,我在第一步中错过了'^',因此错误是有0个参数..

于 2020-08-03T11:01:55.150 回答