Ask a Question

MissingMethodException: No signature of method

wiseAcre
Occasional Contributor

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

13 REPLIES 13
wiseAcre
Occasional Contributor

BTW:  the "log.infor" is a typo I've already caught.

Hey @wiseAcre 

 

the groovy experts are better placed to answer this than me, but I'll give it a go.

 

your script is as follows:

 

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")
}

 

 

so looking at your script, youre storing the ReferenceID variable as a TestCase property entitled ReferenceID

Then you're casting the ReferenceID to integer and adding a 1 and naming that variable as 'ReferenceID' as well

Then you're saying - if the updated 'ReferenceID' variable value is < 990000, then you want to set the TestCase property as the previously updated ReferenceID - is that right?

also - after the log.info line -you have a testRunner.gottoStepByName ("ReferenceID") - does this mean you've also got a teststep called ReferenceID?  Don't really understand what you intend to do here

 

this is a bit confusing - I tend to separate my names as much as possible rather than re-use as this has caused me problems in the past

also - another point - setProperty syntax typically requires two values - e.g. setProperty("attributeName", attribute)

 

I haven't got an machine to debug at moment and I'm kinda guessing about what you need but try something like the following:

 

 

def ReferenceID = context.expand ('${#TestCase#ReferenceID}');
ReferenceID_incremented = ReferenceID.toInteger() + 1;

if (ReferenceID_incremented < 990000) {
testRunner.testCase.setPropertyValue("RefID_increment", ReferenceID_incremented);
log.info "RefID_increment"

}

 

 

try the above and see what you think - bit unsure if you need to cast the integer back to string - but it depends on what you want to do 

 

If you can explain exactly what you want to do  cos I didn't really understand the gotoStepByName command in relation to your description - that would help too

 

ta

 

Rich

 

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
wiseAcre
Occasional Contributor

Rich, 
Thank you for your response, the script below works in the Groovy editor, will update if/when I confirm it is incrementing the xml payload parameter. 
Credit for this solution goes to Stackoverflow:  https://stackoverflow.com/questions/55167067/soapui-how-to-increase-value-by-1-in-property-transfer-...

 

// THIS WORKS INCREMENTING IN THE TEXT EDITOR
def ReferenceID = testRunner.testCase.getPropertyValue("ReferenceID");
ReferenceID = ReferenceID.toInteger() + 1;

if (ReferenceID < 990000) {
testRunner.testCase.setPropertyValue("ReferenceID", ReferenceID.toString());
}

log.info context.expand ('${#TestCase#ReferenceID}')

 

Steve

PS.  I changed the name of the question to reflect the solution.

Hey @wiseAcre 

 

yup!  stackoverflow's saved my life on a number of occasions!

 

nice one!

 

Rich

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
wiseAcre
Occasional Contributor

Return of the MissingMethodException: This was the title of the initial post, but the problem / issue is Auto-incrementing a parameter in an xml payload.  Here is working code for the Groovy editor, new to this script is addition of the XMLHolder library to update xml files:

 

import com.eviware.soapui.support.XmlHolder //assists transfer'g values to payload


def ReferenceID = testRunner.testCase.getPropertyValue("ReferenceID");
ReferenceID = ReferenceID.toInteger() + 1;

if (ReferenceID < 990000) {
testRunner.testCase.setPropertyValue("ReferenceID", ReferenceID.toString());
}
log.info context.expand ('${#TestCase#ReferenceID}')

                                                       // Create script to update the XML payload and auto-increment it for the next req

def RefID = testRunner.testCase.getPropertyValue("ReferenceId");                //  Create object for incrementing payload value
testRunner.testCase.setPropertyValue("RefID", ${RefID.toInteger() + 1});      //  NOW GETTING A 'MISSING METHOD EXCEPTION' error here
def xmlAdd = new XmlHolder(RefID)                                                                      //Create object for xmlHolder class

xmlAdd.setNodeValue("//std:FSMSHeader/std:ReferenceId",RefID);                     // xpath to target param
def newAddXml = xmlAdd.getXml();                                                                        // Update the param

                                                                                                                                 // Update the Custom Properties Values for the next request
testRunner.testCase["<myTestCase>"].testSteps["add"].setPropertyValue("ReferenceId",newAddXml)

 

Any advice on how to clear the Missing Method Exception  Above?
Also, obviously the payload.xml file has been updated as follows:
<v1:ReferenceId>${#TestCase#ReferenceID}</v1:ReferenceId>

 

Hey @wiseAcre 

 

It seems like this is getting waaaaaaaaaay more complicated than it needs to be.  Are you using ReadyAPI! or SoapUI?

 

You don't really need the tail end of the script - once you've incremented the RefID value, can't you just use the GetData function to do the work for you of picking up the incremented value?

 

Don't understand

 

Can you just explain (again) your use case - forgive me - but from what I understand, you just need to increment an existing ref id for a subsequent request which doesnt need anywhere near all that groovy - you just need a little bit.

 

So can you just explain from scratch exactly what you want to do.

 

i.e. is the ReferenceID generated from the testcase's previous response or is it hardcoded to a TestCase property at the start?

are you passing this incremented ReferenceId to another teststep within the same testcase OR do you need this incremented RefId for a teststep in another testcase?

Can you just describe the teststep hierarchy you have in your testcases at the moment (list what test steps you have in your testcase and the sequence of the steps)?

 

Sorry - I need to go back to basics to make sure I'm not misunderstanding.  I'm pretty literal with no imagination so I need to make sure I really understand what you need before I can fix your groovy/come up with an approach where you dont need too much groovy. 

 

nice one,

 

Rich

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
wiseAcre
Occasional Contributor

Ritchie,

This is my first experience using Groovy scripts and setting up a load test with multiple test steps, I've been using a Udemy course on Webservices/Rest API Testing so I have what I can only assume is a good reference.  That said, the course does not cover all, here is my use case:

 

1.  Eight test step requests from Oracle OIBEE projects have been gathered to form a Load Performance Test Suite

 

2.  Each test step's payload.xml file needs to have the ReferenceID value incremented each time a request is sent otherwise the system will error and it will not be processed (nor assigned a TransactionID).

 

3.  I have Groovy script incrementing the ReferenceID in the groovy console, solution was found on Stackoverflow as noted.

 

4.  Now I need to sync the script with the payload.xml so each time I send a request from the test step itself, the RefID auto-increments.  Currently, if I increment the Script and then execute a Request, the ReferenceID is incremented, but if I do NOT increment the Script and then execute  a Request, the new Request shows the same ReferenceID as the previous one, though the TransactionID does increment, but that request is errored.

 

5.  Finally, after my script is functioning, I'll use it in all 8 of the test steps so when I throw off a Load Test with the 8 test steps all of the requests will at least process to the extent that each request will be assigned a new Reference & TransactionID, whether they error in a system if they overload is another issue, but not my concern.

 

Thanks for your interest.

Stephan

Hey @wiseAcre,

Just to be clear, i wasnt criticising your groovy, it just looked like a lot of it was superfluous to requirements which made me think i was misunderstanding something.

More questions:

Q1. What is the datatype and minlength and maxlength of the ReferenceId

Q2. Does the ReferenceId have to be incremented or does it just need to be unique?

Q3. Going on memory here cos im on my phone. In the original script you had an if clause something like 'if ReferenceId > 999000'. Can you just explain what this value was and what the purpose of the if clause was supposed to do?

Ta

Rich


When you say the
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
wiseAcre
Occasional Contributor

 

Ritchie,

 

For this testing environment, the ReferenceID does not have  a min or max length, it simply needs to be unique.  I actually tried another solution where I used the java mathRandomUtils library to generate a random number, but that generated negative numbers too so I canned that.  The IF statement with a max value is simply a loop control mechanism.

No criticism taken, when I can get this whole thing worked out, I'll post it as a complete solution.




cancel
Showing results for 
Search instead for 
Did you mean: