Forum Discussion
JimL
14 years agoContributor
Hi,
I think that I'm getting close to getting this working, but I'm running into problems with the way that Groovy treats variables, numbers and strings, I think.
Here is my current test code, in a Groovy test step:
That works fine if I set max_request_number to something less than 10, i.e., 9 works.
But, if I set cur_request_number to 0 and max_request_number to, say, 11, it blows up after the 9th run, because it looks like the "cur_request_number++" line is incrementing cur_request_number to a semi-colon (":")!!
I hope that someone who's familiar with Groovy can take a look at the above, and tell me what's wrong??
Thanks,
Jim
I think that I'm getting close to getting this working, but I'm running into problems with the way that Groovy treats variables, numbers and strings, I think.
Here is my current test code, in a Groovy test step:
def cur_request_number = testRunner.testCase.getPropertyValue("cur_request_number");
def max_request_number = testRunner.testCase.getPropertyValue("max_request_number");
log.info "INITIAL cur_request_number=[" + cur_request_number + "]"
log.info "INITIAL max_request_number=[" + max_request_number + "]"
cur_request_number++;
log.info "BUMPED cur_request_number=[" + cur_request_number + "]"
if (cur_request_number == max_request_number) {
log.info "In the IF about to reset cur_request_number to 1";
cur_request_number = "1";
}
// set the cur_request_number property (either the incremented one, or "1")
testRunner.testCase.setPropertyValue("cur_request_number", cur_request_number);
cur_request_filename = "E:/SOAPUI-PROPS/testprops" + cur_request_number.toString() +".txt";
log.info "READING FROM Request file [" + cur_request_filename + "]"
props = new java.util.Properties ()
file = new File("E:/SOAPUI-PROPS/testprops.txt")
if(!file.exists()) {
log.info "No file found at E:/SOAPUI-PROPS/testprops.txt"
}
else {
log.info "max_request_number=[" + max_request_number + "]"
log.info "In the ELSE, cur_request_number=[" + cur_request_number + "]"
//testRunner.testCase.setPropertyValue("cur_request_number", cur_request_number);
log.info "Found E:/SOAPUI-PROPS/testprops.txt"
fis = new FileInputStream (file)
props.load (fis)
requestid = props.getProperty ( "requestid" )
log.info "requestid = [" + requestid + "]"
dnstring = props.getProperty ( "dnstring" )
log.info "dnstring= [" + dnstring + "]"
testRunner.testCase.setPropertyValue("requestid", requestid);
context.requestid = requestid;
log.info "Finished setting 'requestid' property"
testRunner.testCase.setPropertyValue("dnstring", dnstring);
context.dnstring = dnstring;
log.info "Finished setting 'dnstring' property"
}
That works fine if I set max_request_number to something less than 10, i.e., 9 works.
But, if I set cur_request_number to 0 and max_request_number to, say, 11, it blows up after the 9th run, because it looks like the "cur_request_number++" line is incrementing cur_request_number to a semi-colon (":")!!
I hope that someone who's familiar with Groovy can take a look at the above, and tell me what's wrong??
Thanks,
Jim
Related Content
- 5 years ago
- 3 years ago
- 6 years ago
Recent Discussions
- 16 hours ago
- 16 hours ago