Overview
The Makers BTG Tests framework supports multiple test environments through theserenity.conf configuration file. This allows you to easily switch between QA, Staging, and other environments without modifying code.
Environment Configuration
Environments are defined in theenvironments block of serenity.conf:
serenity.conf
Available Environments
QA Environment
Used for quality assurance testing with the latest features
Staging Environment
Pre-production environment that mirrors production configuration
QA Environment
Base URL:
https://qa.btgpactual.comThe root URL for web UI tests in the QA environment.API Endpoint:
https://api-qa.btgpactual.com/v1The base endpoint for API tests in the QA environment.Staging Environment
Base URL:
https://stg.btgpactual.comThe root URL for web UI tests in the staging environment.API Endpoint:
https://api-stg.btgpactual.com/v1The base endpoint for API tests in the staging environment.Switching Environments at Runtime
Using System Properties
You can switch environments at runtime using theenvironment system property:
If no environment is specified, Serenity will use the default configuration values (non-environment specific settings).
Accessing Environment Variables in Tests
Using EnvironmentSpecificConfiguration
In Screenplay Tasks
Adding New Environments
To add a new environment (e.g., production), updateserenity.conf:
serenity.conf
Best Practices
Use Environment-Specific Data
Use Environment-Specific Data
Store environment-specific test data (credentials, test accounts) in separate configuration files or environment variables, never hardcode them in tests.
Default to QA
Default to QA
Configure your CI/CD pipeline to use QA as the default environment for automated test runs.
Isolate Staging Tests
Isolate Staging Tests
Run staging tests separately from QA tests, especially before production deployments.
Document Environment Differences
Document Environment Differences
Maintain documentation of any configuration differences between environments that might affect test behavior.
Troubleshooting
Environment Not Loading
If your environment configuration isn’t being applied:- Verify the system property is correctly spelled:
-Denvironment=qa - Check that
serenity.confis insrc/test/resources/ - Ensure the environment name matches exactly (case-sensitive)
- Review test logs for configuration loading errors
Wrong URLs Being Used
Environment configuration is loaded at test startup. Changes to
serenity.conf require restarting the test execution.