We have a Cucumber BDD test project using C# Specflow. The application is browser based tested using Selenium WebDriver automation framework.
There are a number of feature files with scenarios:
Customer.feature
@regression @smoke
Scenario: Create_Customer
Given i have logged in with user 'admin' and used the 'TestDB1' database
And i click on the Customer page
@regression
Scenario:Edit_Customer
Given i have logged in with user 'admin' and used the 'TestDB7' database
And i click on the Customer page
Employee.feature
@regression @smoke
Scenario:Create_Employee
Given i have logged in with user 'admin' and used the 'TestDB1' database
And i click on the Employee page
@regression
Scenario:Edit_Employee
Given i have logged in with user 'admin' and used the 'TestDB2' database
And i click on the Employee page
Each scenario currently logs in, selects a database from the login page and then logs out at the end of the test. Test runs use the tags to select the scenarios. Tests are not in parallel atm.
The login process (the 'Given' step) takes 30 seconds per scenario.
It's been requested that it's changed so we only login once and then stay logged in for the duration of the test run using the same browser session, UNLESS a different database is then required on the next scenario in which case it should logout and then login using the new database. So a hypothetical run with no control of run order:
Scenario:Create_Customer starts and logs in selecting 'TestDB1' and stays logged in.
Scenario:Create_Employee starts doesnt login as the database is set to 'TestDB1' and stays logged in.
Scenario:Edit_Customer starts, needs a different db and so logs out and logs back in selecting 'TestDB7' etc..
There is nothing visible in the application to show what database was selected at login. Any idea what approach could be considered across multiple features in a test run? From the sound of it, I need to somehow perpetuate a "database" value and "currentlyLoggedIn" value (or identify the application is still open) across the test run but obviously can't use the ScenarioContext/FeatureContext.
I appreciate this is not a good idea as test independence should be maintained but surely other people have considered reducing the repeated logins? If this really shouldn't be done, any suggestions on how to save this 30+seconds per test?