Reputation:
I am very new to Cucumber and I have a situation where I have to run a certain Scenario A present in Feature A before I can run Scenario B present in Feature B. I am wondering how can I do this in cucumber, I have used @After and @Before in a feature but how can I take care of cross feature dependencies like this. Thanks a lot.
Upvotes: 2
Views: 1381
Reputation: 13719
Your scenarios must be independent (like any kind of tests be it acceptance tests, unit tests etc.). Never make assumptions about the order of tests/specs.
If you need to perform common operations before and after each scenario (or each scenario tagged with tag), use Before
and After
hooks.
If you need to do same initialization before each scenario in the feature and you want to be explicit about this initialization in the text of your Feature
, you can use Background
:
Feature: some feature
Background: logged in
Given I am logged in as administrator
Scenario: some scenario where user will be logged in
Note: Before
hooks run before Backgrounds
Upvotes: 5