How to call a feature inside another feature in cucumber-jvm? How to call a feature inside another feature in cucumber-jvm? selenium selenium

How to call a feature inside another feature in cucumber-jvm?


Did you see the Background DSL-feature? It would work for your case but is probably not what you're literally asking about. In this case you can require user to create profile by:

Feature: Create Profile  Background:    Given I create a profile    And I should be navigated to Home Page    And sign out link should exist  Scenario: Create Profile    # do nothing because all actions are in background  Scenario: Go to my account page    When I go to my account page    Then I should be navigated to the my account page

But you have to merge the two your feature files into a single feature file.

Also take a look at @Before and @After cucumber annotations - so that you can run some code to initialize (or create) an account for your test if previous solution wouldn't work for you.


The Create Profile feature specifies the Given/When/Then, because that's what is driving the feature implementation.

Many other features will require the existence of a valid profile. You should not create the profiles for these features by repeating the specification from Create Profile. Instead, include something along the lines of Given I have a valid profile (maybe in the Background section) and wire that through to fixture code that creates a profile.