Swapping environments in Serenity tests
Swapping out the application environment to run your Serenity tests is quick and easy in the beginning when you only have a few tests. However, as your projects grows, and you start to include more tests, it can quickly become a mission to change that environment. Below is a step by step guide which will help you abstract your application environment in all your Serenity tests.
Step 1: Create a file to store all your application environment
The sole purpose of this class is to store all the possible environments in which you can run your Serenity Tests.
Here is an example:
Step 2 : Create a file to store all your application constants
The sole purpose of this class is to store all the constants in your test suite. It’s in this class where you will swap out the application environment in which you wish to run your tests by changing the variable ACTIVE_ENVIRONMENT.
Below is a code example:
Step 3 : Reference the ACTIVE_ENVIRONMENT in your tests
Lastly, change all your tests to reference the ACTIVE_ENVIRONMENT constant, and your good to go.