cancel
Showing results for 
Search instead for 
Did you mean: 

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

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

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
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)
}
Highlighted
Community Manager

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

Thank you, @JoostDG!

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

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
New Here?
Join us and watch the welcome video:
6 / 7 API Testing Mistakes Video
Top Kudoed Authors