Forum Discussion

thePantz's avatar
5 years ago

Prompt before executing on a specific environment

I've created a beforeRun event to prevent mistakenly executing a test on my production environment like so:   import javax.swing.JOptionPane; def env =
  • richie's avatar
    5 years ago
    Hey @thePanz,

    I don't know if this approach would be too much rework for you, but an approach nmrao suggested to me in regards to environmental config/environment switching might help ensure you don't execute on the wrong environment.

    Rao suggested that i create a single properties file for each environment....1 for dev, 1 for test, 1 for pre-prod, 1 for prod, etc.

    Essentially before executing any tests, i load in a specific properties file, which loads in all my environmental variables setting them as project level custom properties.....mostly i work in dev and test, but the important point being that because you have to load in the specific file to switch to a different environment and i tend to execute in prod infrequently, this approach helps handle the risk of executing in prod or pre-prod by accident. Its obviously not foolproof, but because i always load in a properties file before each execution (and i tend to execute im dev and test mostly) its part of my process now to pick the correct file so its very unlikely i'll execute my tests in the wrong environment.

    Perhaps this approach would help you too? All cred goes to Rao....he suggested this approach and its great for a number of reasons....i use this approach for every new project i work on now.