我的资源采用这种格式“testing/101/getCustomer/99”
在这里,我需要通过 groovy 动态更改“101”和“99”部分,以便我可以在同一个测试用例中运行多个值。我查看了 ReadyAPI 的内置功能,但它并没有那么有用。
我也找到了这个链接,但是它改变了整个项目中的资源。我正在寻找的解决方案是在测试用例级别。因为我的每个测试用例都会有不同的 url。
https://community.smartbear.com/t5/SoapUI-Open-Source/How-to-set-the-resource-path-at-run-time-while ...
任何帮助将不胜感激。
这是我到目前为止尝试过的
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"));
}
}