The first scenario is run as part of the feature file registration.feature (feature1) and has the following content:
Scenario: User can register as a Free account Given I am on the home page When I navigate to the Register page And set all required fields for "Free" on the page And check that info about successful registration is shown And activate account Then I copy the Free user information in a data file
Then I would like to run the following feature under the upgrade_accounts.feature(feature2)
Feature: Upgrade accounts As an QA Engineer I would like to upgrade my accounts to other types So I can make sure upgrade functionality is working properly Scenario: Existing free account is upgraded to premium Given I navigate to the login page When Sign in as free account retrieved from file And I navigate to updgrade accounts And I select premium account and submit Then Verify premium package is active
My concerns are about how I implement the connection between these two features using something that applies to step: Then I copy the Free user information in a data file
from feature1 and When Sign in as free account retrieved from file
on feature2.
So I guess the question is: What approach(gem) would be best to use in order to copy data from web page into a file and the read it and use it again?
Thank you!
In general, creating dependencies between features files is discouraged. You want to be able to run features independently with deterministic results, so coupling features through state will likely produce brittle (and breakable) features. For example, it would be impossible to successfully execute upgrade_accounts.feature
without executing registration.feature
.
If you haven't picked up The Cucumber Book , it's good guide and resource. It recommends setting up application state through before hooks in /support/hooks.rb
Like Orde says, each scenario is unique & independent:
Scenario: User can register as a Free account
Given I am on the home page
When I register for a free account
Then I get a message that registration is successful
And my account is active
Scenario: Existing free account is upgraded to premium
Given I have a free account
When I updgrade my account to a premium account
Then my premium package is active
Two features, two completely separate tests. If you have one single step that injects a free account into the system Given I have a free account , you will not end up with have a failure in upgrading because the step to register the free account failed.
Also, I took the liberty to cut down on the steps to create and verify the account. All the navigation and such are not necessary in the scenario. That is done in the step definition.
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.