简体   繁体   English

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

[英]Can I skip undefined steps in Cucumber?

I have the same feature file that is used by frontend and backend testing, which have their own step definitions. 我具有前端和后端测试使用的相同功能文件,它们具有自己的步骤定义。 For backend, I want to skip a few steps (eg frontend navigation). 对于后端,我想跳过一些步骤(例如,前端导航)。

I can either write empty step definitions, which will mark the steps as completed. 我可以写空的步骤定义,这会将步骤标记为已完成。 I would rather if they were marked as "skipped" instead. 我希望将它们标记为“已跳过”。

There is the problem though: If I have an undefined step, the test will fail. 但是,存在一个问题:如果我有未定义的步骤,则测试将失败。 How can I configure Cucumber to skip the step instead and continue afterward? 如何配置Cucumber跳过该步骤,然后再继续?

I would prefer Javascript answers 我更喜欢Javascript答案

I would define the step anyhow. 无论如何,我将定义步骤。

Your step definition would go something like this: 您的步骤定义将如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM