Groovy在循环中设置具有令牌号的属性。
在下面的示例中,我们使用不同的输入数据执行5次请求。 例如,是否可以同时保存每个请求的令牌号和在属性中设置的令牌号 token1=来自request1的令牌 token2=来自request2的令牌 下面是groovy代码:Groovy在循环中设置具有令牌号的属性。,groovy,soapui,Groovy,Soapui,在下面的示例中,我们使用不同的输入数据执行5次请求。 例如,是否可以同时保存每个请求的令牌号和在属性中设置的令牌号 token1=来自request1的令牌 token2=来自request2的令牌 下面是groovy代码: import groovy.json.JsonSlurper def MAX_LIMIT = 2 def countries = new Object[MAX_LIMIT] countries[0] = "India" countries[1] =
import groovy.json.JsonSlurper
def MAX_LIMIT = 2
def countries = new Object[MAX_LIMIT]
countries[0] = "India"
countries[1] = "US"
// Invoke Method
GetCountries(countries);
// Method Definition
void GetCountries(Object[] countries)
{
for(int i=0; i<2; i++)
{
// Assign values to the global properties and call the servive
com.eviware.soapui.SoapUI.globalProperties.setPropertyValue("CountryName", countries[i] )
// Call GetCitiesByCountry service to run
def testStep=testRunner.testCase.testSteps['GetCities'];
testStep.run(testRunner,context);
}
}
也许我不明白你的问题,但请改变一下:
.setPropertyValue ( "token", result.data.token )
致:
有人能解释一下为什么我的问题是-1吗
.setPropertyValue ( "token", result.data.token )
.setPropertyValue ( "token" + i, result.data.token )