How to retrieve the selected environment from the command line (-E) in a groovy script?
I know how to retrieve the active environment from the project (UI) using this solution.
However I want to know how to get the environment which is provided as a commandline parameter (e.g. when started via soaprunner.bat) like :
Is this possible with groovy scripting ?
The link you mentioned has step to retrieve the environment name using groovy only.
And the command line option you mentioned is to set the environment.
So, do not understand the problem.
When the SoapRunner.bat is used to run a test, the environment can be supplied using that -E command line parameter.
Now inside my test, I want to use a groovy script to retrieve the value for this -E command line parameter so that I can determine the environment. This environment is then used by the script script to do some specific business logic. (I don't want to use the saved selected environment from the project, but I want to use this value.)
And you already know how to access environment name in the groovy script based on the link you provided in the question i.e.,
Hope it is clear and no confusion.
I don't think that statement
is not correct.
I have the feeling that the value saved in the project-url is overwrting the value on the command-line.
I'll do some more testing.
I'm not sure if this is relevant or not, but quite a while ago I raised a very similar sounding issue with SmartBear support about the -E command line parameter being ignored. SmartBear support responded with:
"I was able to reproduce the issue on our end. I will create a bug once our developers approve, The logs are not updated but fortunately it takes the environment variables even if the log shows a different active environment. Thanks a lot for bringing this issue."
This issue was logged with the internal defect number SOAP-1741.
Please note, I raised this issue with a very old version (SoapUI Pro 5.1.1) but because 95% of our tests were run in a single environment and the fact that no date could be given for a fix we got in the habit of saving our projects in the "correct" environment as a work around. I've actually no idea if this has been fixed or not.
Please post any follow up from support here as I'd be interested to know.