【问题标题】:when Cucumber values are defined at the end of scenario outline, get an error当 Cucumber 值在场景大纲末尾定义时,会出现错误
【发布时间】:2020-08-02 16:53:13
【问题描述】:

我正在尝试使用 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

谢谢..

【问题讨论】:

  • 可以添加步骤定义吗?
  • @GregBurghardt:当然,添加..

标签: java testing cucumber


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2018-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-04
    相关资源
    最近更新 更多