【问题标题】:Alternative parameter type in CucumberCucumber 中的替代参数类型
【发布时间】:2020-12-26 18:27:09
【问题描述】:

我有以下 Cucumber 步骤,我想测试它的第 1、2、3 等项。

When user makes a request for the 1st item

这里是它的实现

@When("user makes a request for the {int}st/nd/rd/th item")

看起来是正确的,但测试没有运行,我收到错误Parameter types cannot be alternative: ... 怎么了?

【问题讨论】:

    标签: cucumber gherkin scenarios


    【解决方案1】:

    替代项由空格分隔,因此参数强烈绑定到替代项。所以它期待{int}stndrdth

    您将不得不使用正则表达式。例如:

    ^user makes a request for the (\d+)(?:st|nd|rd|th) item$
    

    【讨论】:

      猜你喜欢
      • 2021-06-11
      • 1970-01-01
      • 2017-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-25
      • 2011-04-09
      相关资源
      最近更新 更多