cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
New Contributor

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

TestSuite: Setup Script: How to get current environment selected using the groovy script?

1 ACCEPTED SOLUTION

Accepted Solutions
Contributor

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

Sorry, took the liberty to provide an anwser here Smiley Wink

 

 

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)
}

View solution in original post

4 REPLIES 4
New Contributor

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

Issue is resolved

Community Manager

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

That's great to hear!

Do you mind sharing the solution you've found?  It will help other users in the future.

---------
Tanya Gorbunova
SmartBear Community Manager

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!
Contributor

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

Sorry, took the liberty to provide an anwser here Smiley Wink

 

 

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)
}

View solution in original post

Community Manager

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

Thank you, @JoostDG!

---------
Tanya Gorbunova
SmartBear Community Manager

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!