Forum Discussion

gagarwal's avatar
gagarwal
New Contributor
6 years ago

TestSuite: Setup Script: How to get current environment selected?

TestSuite: Setup Script: How to get current environment selected using the groovy script?
  • JoostDG's avatar
    JoostDG
    6 years ago

    Sorry, took the liberty to provide an anwser here :smileywink:

     

     

    def active_environment = testSuite.project.activeEnvironment.name

     

     

    Bonus: Handy script to enable/disable some testcases based on your environment name looks like this:

    def active_environment = testSuite.project.activeEnvironment.name
    
    def tc1 = testSuite.getTestCaseByName("GET xxxxxxxx")
    def tc2 = testSuite.getTestCaseByName("GET yyyyyyyy")
    
    if (active_environment != "Sandbox" && active_environment != "TEST" && active_environment != "BETA"){
    log.info ("Active environment = "+ active_environment + " --> Higher than BETA, so we do not have a mock authorization service available ------> disabling GET test cases")
    tc1.setDisabled(true)
    tc2.setDisabled(true)
    }
    else{
    tc1.setDisabled(false)
    tc2.setDisabled(false)
    }