Forum Discussion

mmoser18's avatar
mmoser18
Frequent Contributor
8 years ago

Help needed to understand error message

Hi - I am starting to really get the hang for Groovy to extend the capabilities for soapUI and make it easier to use.

In several of our test cases we have literally dozens of XPath assertions to validate the number of certain tokens in the message.

 

I now wanted to consolidate these into a single assertion using a groovy script:

 

So, instead of having e.g. three XPath scripts assertions like

 

XPath Expression Declare:

count(//Airport)

and expected result:

 20

 

I want to have a single script assertion that reads:

tests.TokenCounter.count_tokens(log, context, messageExchange,
[['//Airport','20'],
 ['//Position','20'],
 ['//CityCode','45'],
])

The input argument would be an array of name and value pairs, each with an xpath expression and a result.

This would be easier to edit and more compact. I guess you get the idea...

 

So, I wrote me a corresponding Groovy class, packed it up as a .jar and put it into the ...\bin\ext folder.

But for some reason that I don't quite understand, yet, I am getting the following error when the above script assertion executes:

 

--> Bug! exception in phase 'semantic analysis' in source unit 'Script2.groovy' The lookup for tests.TokenCounter caused a failed compilation There should not have been any compilation from this call.

 

I simply don't understand what soapUI is trying to convey to me here. Could you please elaborate a bit?

 

Michael

 

3 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    You mean to say that the above line has problem or do you have some more script to show?

    By the way, you can use a map to send the xpath details instead of multi-dimensional array.
    • mmoser18's avatar
      mmoser18
      Frequent Contributor

      It the above line that obviously has an issue. My script's method (tests.TokenCounter.count_tokens) isn't even called at this point.

      I will try using a list, but in principle, using a two-dimensional array should also be possible, shouldn't it?

      • kondasamy's avatar
        kondasamy
        Regular Contributor

        Could you please share the implementation part of count_tokens method or the complete groovy script for further examination?

         

        Thanks,

        Kondasamy