thePantz
6 years agoContributor
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 = testRunner.testCase.testSuite.project.activeEnvironment.name if (env == "Production") { answer = JOptionPane.showInputDialog(null, "Warning, you're about to execute in PRODUCTION. \n\nProceed? \n\nType \"Yes\" to continue or click Cancel to abort.\n\n", "Input", JOptionPane.WARNING_MESSAGE); if (answer.toLowerCase() != "yes") { testRunner.cancel("Production Run aborted due to user input.") } }
The issue is I can get around this easily if I run an individual step as the beforeRun step only looks at the whole test case being run. I've tried doing this at the beforeStep event but then I am prompted for every step...
Has anyone tried doing something similar? I'm curious if there is a better solution that I'm missing.