Ask a Question

How to retrieve the selected environment from the command line (-E) in a groovy script?

stef
Occasional Contributor

How to retrieve the selected environment from the command line (-E) in a groovy script?

Hi all,

 

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 :

-ELOCAL_ENV

Is this possible with groovy scripting ?

7 REPLIES 7
nmrao
Community Hero

It is a bit confusing.

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.


Regards,
Rao.
stef
Occasional Contributor

Dear Rao,

 

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

nmrao
Community Hero

do you mean testrunner.bat?


Regards,
Rao.
stef
Occasional Contributor

Indeed. TestRunner.bat

Sorry for the confusion.
nmrao
Community Hero

Ok. testrunner will inject the envrionment name that you needed from command line.

And you already know how to access environment name in the groovy script based on the link you provided in the question i.e.,
testRunner.testCase.project.getActiveEnvironment().name

Hope it is clear and no confusion.


Regards,
Rao.
stef
Occasional Contributor

I don't think that statement

 

testRunner.testCase.project.getActiveEnvironment().name

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.

Radford
Super Contributor

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.

 

It might be an idea to raise an issue with SmartBear support (If you've got time to burn you could check through all the release notes).

 

Please post any follow up from support here as I'd be interested to know.

cancel
Showing results for 
Search instead for 
Did you mean: