简体   繁体   中英

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?

I would prefer Javascript answers

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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