Forum Discussion

bmgriner's avatar
bmgriner
Frequent Contributor
13 years ago

Resetting Endpoint in Script (Environments Feature)

I have a script that for certain test cases resets the default endpoint used for only that test case. When I use anything but Default in the environments, once I make the changes for the one test case, it has made that same change for every other test case. It is like the endpoint value is a shared resource among all the test cases and when I change it on one test case, it changes all of them.

This basically made the Environments feature worthless to me.
  • Hi,

    Just so we understand: you want to be able to set a specific requests endpoint through a script while a non-default environment is selected?

    thanks!

    /Ole
    SmartBear Software
  • bmgriner's avatar
    bmgriner
    Frequent Contributor
    Yes, that is what I want. Here is some more description.

    I have a script that looks like this that I run against every test step in a few test cases:

    def static setTestStepEndpoint(testStep, log, String endpoint) {
    if (testStep instanceof RestTestRequestStep || testStep instanceof WsdlTestRequestStep) {
    testStep.getTestRequest().setEndpoint(endpoint)
    log.info("Endpoint for the test step + [" + testStep.getLabel() + "] is now [" + testStep.getTestRequest().getEndpoint() + "]")
    }
    }


    If I have an environment set other than "Default", then the above code changes that Environment's default endpoint, and every test case after the above code is run uses the new endpoint instead.

    I want the ability to have one or more test cases run against a non-standard endpoint without breaking the rest of my test cases.
  • bmgriner's avatar
    bmgriner
    Frequent Contributor
    I thought about adding to the script a call to retrieve the existing endpoint, save it in a property, and then set it back once the test case was done. This, however, will not work if I run the test cases in parallel.
  • Hi,

    ok - hmm... I can't see any way to achieve this currently - I'll add a feature request to the backlog, maybe you can set the environment-specific endpoint to use property-expansion from a property that you change for this specific execution!?

    regards!

    /Ole
    SmartBear Software