MissingMethodException: No signature of method
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MissingMethodException: No signature of method
RE: MissingMethodException: No signature of method Error on LINE 5
I'm trying to increment a param in the xml payload" ReferenceID, and getting the above-mentioned error:
I changed the "setPropertyMethod" to "getPropertyMethod" and the error changed to "groovy.lang.MissingPropertyException: No such property: ReferenceID
Again, I'm trying to increment the parameter, so the SET method makes sense to me
def ReferenceID = context.expand ('${#TestCase#ReferenceID}');
ReferenceID = ReferenceID.toInteger() + 1;
if (ReferenceID < 990000) {
testRunner.testCase.setPropertyValue('${TestCase#ReferenceID}'); //LINE 5 Error
log.infor "ReferenceID" + ReferenceID;
testRunner.gotoStepByName("ReferenceID")
}
Any idears?
Thanks, wiseAcre
- Labels:
-
Function Tests
-
Performance Tests
-
REST
-
Scripting
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If it just has to be unique this is even easier.
You had the right idea with the random number generator.
Theres a number of different ones i use....a guid/uuid generator, number generator based on current date/time.
We can use a dynamic scripting property based on the date/time of when it executes. You wont need any of the groovy.
Im on my phone and cant remember the date/time option, but i can show you using the guid/uuid dynamic scripting option.
In your payload, instead of creating loads of groovy to 1. create a number, 2. pass it to the payload, 3. Increment the number and then repeat. You just need to add in the dynamic scripting property instead.
E.g.
For json payload:
"jsonAttribute": "$ {=java.util.uuid.randomuuid()}"
Or for xml payload:
<element1>$ {=java.util.uuid.randomuuid()}</element1>
When the payload is submitted it will dynamically generate a unique GUID/UUID value in the payload.
I'll dig around tomorrow and see if i can find the equivalent dybamic scripting property based on current date/time. Its i think 10chars long rather than the 30chara the GUID/UUID is made up of.
I think we've sorted your problem out fella!
Nice one!
Rich
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ritchie,
I'm still at loggerheads on this one: issue is still passing the incremented value to the xml payload, here's what I have including libraries. BTW: the udemy video I've been watching states that one must use the XmlHolder & the WSDL library. What's been killing me are "MissingMethodException" errors. I've included all of my attempts--commented out--to date. I've been stumped for so many hours on this, I decided to start a Groovy course from scratch. The Java Devs are too busy with their stuff so I'm left on my own. I'll get it eventually, question is "when is eventually?" Again, thank you for your interest in this issue.
import java.util.Random;
import org.apache.commons.lang.math.RandomUtils
import com.eviware.soapui.support.XmlHolder //assists transfer'g values to payload
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext
def ReferenceID = testRunner.testCase.getProperty("ReferenceID");
def RefID = ReferenceID.value = RandomUtils.nextInt(new Random()); //new Random(System.currentTimeMillis());
log.info (RefID);
// Above works
testRunner.testCase.setPropertyValue("ReferenceID", $('{#RefID}' + 1)); // Getting Missing Method Exception error with this
//log.info context.expand('{$#TestCase#ReferenceID}');
//def RefID = testRunner.testCase.getPropertyValue ('${#TestCase#ReferenceID}');
//def xmlRef = new XmlHolder(RefID);
//log.info context.extent(ReferenceID.value);
//def RefID=testRunner.testCase.setPropertyValue("ReferenceID",('${#TestCase#ReferenceID}'));
//def updateRef = new WsdlTestRunContext("ReferenceID");
//log.info context.expand("RefID");
// Call the service AddTestStep.run(testRunner,context)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is no more complex business logic, so no need to let a problem complication.
you are able to debug your code line by line since it is simple to run your scripts.
from your code snippet, run set method to setup a property (note: only string value would be saved in properties), if it is ok, then using getPropertyValue() to retrieve your value. there is no magic method for set/get.
After you retrieve value from properties, it treated as string as well, then you may need to convert it type (i.e string to integer).
using context.expand ('${#TestCase#ReferenceID}') to parse value in groovy script step or using testRunner.testCase.getPropertyValue('ReferenceID').
Non case-sensitive for properties. If you would like to set property: testRunner.testCase.setPropertyValue("xxxx", context.expand('${#TestCase#ReferenceID}')) //LINE 5 Error
Thanks,
/Aaron
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So here is the solution for incrementing a parameter in a payload xml file, two requisites to the Groovy are:
* A Property needs to be defined, in this use case it was called "incrementValue"
* The value in-question needs to be 'parameterized', I'm 'P-izing' ReferenceId as follows:
<req:ReferenceId>${Properties#incrementValue}</req:ReferenceId> // Calls the Pre-set Property "incrementValue
and finally only four lines of script are required:
def incrementValue = context.expand('${Properties#incrementValue}');
incrementValue=incrementValue.toInteger() + 1;
incrementValue=incrementValue.toString();
log.info "incrementValue: " + incrementValue; // Optional as this simply prints the text in the groovy editor
testRunner.testCase.getTestStepByName("Properties").setPropertyValue("incrementValue",incrementValue);
I'm labeling this solution as solved, much thanks to Ritchie and others who provided valuable feed-back during the past two weeks.
Cheers, wiseAcre

- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »