Forum Discussion

wiseAcre's avatar
wiseAcre
Occasional Contributor
4 years ago

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

  • wiseAcre's avatar
    wiseAcre
    Occasional Contributor

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

    • richie's avatar
      richie
      Community Hero

      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

       

       

      • wiseAcre's avatar
        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-target

         

        // 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.

  • aaronpliu's avatar
    aaronpliu
    Frequent Contributor

    wiseAcre ,

    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