Writing different tests for different environments

  • We didn't implement automated deployment yet to our Angular 7 project, so environment-based variables (e.g baseUrl) are changed manually, causing the application to crash after deployment a lot due to wrong variable values.

    Does it make sense to write some environment-specific tests to ensure that the correct values are being passed and set and how to go about this (e.g. conditional statements based on node_env, separate test files for each environment, ...)?

    Things I want to keep in mind are:

    • Code coverage
    • Applying DRY to not repeat tests that wouldn't be different based on different environments
    • Should I use E2E or unit tests or both for the mentioned purpose.

  • if it makes sense to write some environment-specific tests ?

    Absolutely! This is also frequently the job of smoke tests which basically assert that the latest deployment was successfull with very simple tests such as 'can I reach the page or do I get a 404'

    Testing the tests is an essential part of any quality automation system.
    You should generally test the tests for:

    • Environment variables set correctly *
    • Page Object Duplicates
    • Page Object Orphans
    • Test Code complexity
    • Test code syntax and linting
    • Test code quality

    In your case smoke tests and environment variable tests should be used.

    *You'll need to think this through. Obviously static code 'does x = 1' does not respect different environments. Also you want to avoid statement like does url = x and username = y and password = z. Think through a system that forces you to update these items. Maybe check the update timestamp of the variables file, maybe use a deployment step or sha to do this.


    Automate the entire process. When you need variables for a given environment, make sure they have to be updated as an automated step of the deployment process.

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2