2

my resource is in this format "testing/101/getCustomer/99"

Here I need to change "101" and "99" part dynamically by groovy so that I can run for multiple values in same test case. I looked into the ReadyAPI's built in feature, but it was not that helpful.

I also found this link, but it changed the resource in the entire project. The solution I am looking for is in test case level. As my each test case will have different url.

https://community.smartbear.com/t5/SoapUI-Open-Source/How-to-set-the-resource-path-at-run-time-while...

Any help will be appreciated.

Here is what I have tried so far

import com.eviware.soapui.impl.rest.RestResource
import java.io.*;
def project = testRunner.testCase.testSuite.getProject()
String restServiceName = "Resource name" (From the Rest Request Properties)
List<RestResource> ops = project.getInterfaces()[restServiceName].getOperationList()

log.info("ops ::"+ops);
log.info("ops size ::"+ops.size());

for (RestResource restResource : ops) {
String pathStr = restResource.getFullPath();
log.info("pathStr first-->"+restResource.getFullPath());

restResource.setPath("testing/101/getCustomer/99");

        if (pathStr.contains("101"))
        {
            restResource.setPath("testing/101/getCustomer/99");
            restResource.setPath(pathStr.replace("testing/101/getCustomer/99", "testing/50/getCustomer/99"));
        } 

}
ktmrocks
  • 361
  • 1
  • 5
  • 18

1 Answers1

0

you could use a testCase level property

first set the the value of res by groovy like below

def x=101
def y=99
def res="testing/$x/getCustomer/$y"
testRunner.testCase.setPropertyValue("resourc",res)

Now the testcase level property is set. It can be used as below wherever you want

${#TestCase#res}
Gaurav Khurana
  • 3,423
  • 2
  • 29
  • 38
  • Gaurav, your solution is for creating custom properties in test case level. What I need is from "REST Request Properties" tab. I want to update the existing Resource from there (basically it works as the method for the end point) To get there click the Rest Request > REST Request Properties > Resource => This will populate when you go and update resource from Project level. I am trying to control it from groovy instead of UI. – ktmrocks Mar 27 '18 at 03:27
  • ok but it should allows to add something like ${#Project#resource} even in properties. So in resource properties(resource) , a variable will stay which you can update via groovy. – Gaurav Khurana Mar 27 '18 at 11:02