简体   繁体   中英

skip scenario cucumber javascript

I am a newbie to cucumber and don't find any relevant information in a cucumber javascript version Basically, I am having 3 scenarios "a", "b" and "c" in a feature file, "a" is the setup scenario which has the login step for example. "b" and "c" are the actual test scenarios for my UI. So if scenario "a" fails(login fails), I want "b" and "c" to be skipped and reported as skipped in the output JSON file. Can someone please help me out giving an example of how to achieve this? I need some kind of way to skip scenarios in the form of before and after in the hooks.

Note: The cucumber version that I am using is 2.3.1

At first glance (as apparent by my edit history), I read that you wanted to skip scenarios, but I didn't read on further.

What you're asking for is not how cucumber was meant to be used.

Each of the scenarios within cucumber should be completely independent of each other, and should not rely on the outcome of previous scenarios to determine whether or not it should continue with others.

If you're doing set up steps for everything in the feature file:

Background:
   Given I am logged in as "Jerry Tarpin"
   And I am browsing the "search" page

Scenario: ....
   ...

The Background runs for each Scenario within.

If you don't want to log in more than once per feature, in your log in step, check if there is a user logged in, and if it's the right person, don't log in, if it's the wrong person, log out and log in again, and if there is nobody logged in, just log in.

Skipping scenarios in your Before and After hooks means that you'll be less equipped to be able to identify problems with the site under test, especially if there isn't actually a bug on the page, and your site just took longer than usual to load the correct page.

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