【问题标题】:Can I skip undefined steps in Cucumber?我可以跳过 Cucumber 中未定义的步骤吗?
【发布时间】:2019-08-13 22:32:51
【问题描述】:

我有前端和后端测试使用的相同功能文件,它们有自己的步骤定义。对于后端,我想跳过几个步骤(例如前端导航)。

我可以编写空的步骤定义,这会将步骤标记为已完成。我宁愿将它们标记为“已跳过”。

但是有一个问题:如果我有一个未定义的步骤,测试将失败。如何将 Cucumber 配置为跳过该步骤然后继续?

我更喜欢 Javascript 答案

【问题讨论】:

标签: javascript cucumber gherkin


【解决方案1】:

无论如何我都会定义步骤。

您的步骤定义如下所示:

When("I go to the home page", notApplicable);
When("I go to page X", notApplicable);
When("I go to page Y", notApplicable);
When("I go to page Z", notApplicable);

function notApplicableStep() {
    console.log("Skipped. This step is not applicable.");
}

【讨论】:

  • 是的,我忘了指定 :D 但是,这会将步骤标记为“完成”,而不是“跳过”,这是重点。
  • @MilanSmolík:将步骤标记为“跳过”并没有任何好处。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-19
  • 2016-09-08
  • 1970-01-01
  • 1970-01-01
  • 2021-12-27
  • 1970-01-01
相关资源
最近更新 更多