Forum Discussion
if you try to set custom parameters to values from command line via -P parameter then these will be set always for environment that was saved last time.
you have to write testcase which first set new environment and save project and after that you can call your test cases from command line with -P parameter for setting values for the new selected environment
- jaywhar10 years agoVisitor
I'm having the same issue.
we have Environments configured such as Dev, Staging and Prod that map to load balancers.
we have suites of smoke tests that we want to run against individual hosts behind the load-balancer where the api we're testing is addressed at the host level, while the dependencies are tested at the load-balancer level.
I'm trying to make this work by setting the endpoints to be Environment parameters, with different values for the api under test and the dependencies.
eg: if I'm testing our 'Customer' api, which has a dependency on our 'Auth' API, I have the 'Auth' calls configured with an endpoint of something like ${#Project#loadBalancedHost} and the 'Customer' endpoints as ${#Project#directHost}. Each environment has different values for these, and when I execute from Jenkins, I'd like to override 'directHost' so that I can hit each server behind the loadbalancer with the -P option from the command line.
As mentioned earlier in this thread - this is only working for the environement of the project when it was last saved. So if I saved the project with 'Dev' as the active environment, and I run from the command line with -EDev and -PdirectHost=blah
then it the override of directHost works. But if I then run -EStaging -PdirectHost=blah the -P flag is ignored and the value from the Staging environment is used. If I go back into the project, set the environment to Staging and then save and rerun the command, it works as expected.
This seems to be a bug - I'm setting the environment on the command line, but it seems to be applying overrides specified with the -P switch to whatever environment was active the last time the project was saved. I've tried saving the project with the Default Environment active, but this doesn't work either.
- nmrao10 years ago
Champion Level 1
Is it possible to show the issue thru some screen shots and steps to reproduce in a simple manner? - ustim8010 years agoOccasional Contributor
I didn't trust on -E parameter :-) because it never works properly
I guess the problem is that SoapUI first set parameters (via -P) and after that switch environment (via -E).
I use my own solution to switch environment via running "preparing" test case with groovy script that contains something like this:
context.testCase.testSuite.project.setActiveEnvironment(context.testCase.testSuite.project.getPropertyValue("runEnv"))
Expected environment will be set via project parameter runEnv: -PrunEnv and save project via -S.
After that I start my test suite via second run of testrunner and it works properly.