Forum Discussion
reply from smart bear:
This is a known limitation of ReadyAPI’s TestRunner (CLI). When you use the -E <envName> flag, the environment is locked in at runtime startup, and internal changes made during execution via scripts do not impact actual request resolution for endpoint/credentials/etc.
In short:
Changing the environment dynamically via Groovy script during a TestRunner execution has no effect on actual requests.
This works in the GUI because the execution context is fully dynamic — but the CLI loads the environment once at startup, making it immutable during test execution.
One option you can try to do to get around this is to run TestRunner Twice (One per Environment)
Which would probably be the most reliable and maintainable solution:
Run the suite twice, once for each environment:
testrunner.bat -E LOCAL -s "SuiteName" -c "TestCase1" -RJUnit -r <project-file>
testrunner.bat -E CLOUD -s "SuiteName" -c "TestCase2" -RJUnit -r <project-file>
You can pass in shared data through properties, or persist data to disk (via Excel, CSV, JSON) between executions.