提问者:小点点

我可以跳过cucumber中未定义的步骤吗?


我有前端和后端测试使用的相同的特征文件,它们有自己的步骤定义。对于后端,我想跳过一些步骤(如前端导航)。

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

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

我更喜欢Javascript答案


共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.");
}