Forum Discussion
SmartBear_Suppo
Alumni
12 years agoHi Tino,
Sorry for the slow reply. I tried reproducing this, using your exact code. This line
doesn't work. But, the error message I get is different from yours:
Tue Apr 09 13:19:29 CEST 2013:INFO:<XmlTag>No signature of method: static soapui.utils.MyUtils.randInt() is applicable for argument types: (java.lang.Integer, java.lang.Integer) values: [10, 20] Possible solutions: randInt(), randInt(java.lang.Object), randInt(java.lang.Object, java.lang.Object), wait()</XmlTag>
However, the line below:
works fine.
The explanation to this is that scripts written inside property expansions are evaluated as separate scripts (in a vacuum, you could say), and because of this the failing code snippet doesn't recognize that MyUtils has been imported, and thus fails.
Have you made sure that your script is located in the correct folder, set the scripts preferences correctly ("Script library" in "Preferences" -> "soapUI Pro"), and created the correct package structure (SoapUIHomeFolder/scripts/soapui/utils/MyUtils.groovy)?
Sorry for the slow reply. I tried reproducing this, using your exact code. This line
log.info(context.expand('<XmlTag>${=MyUtils.randInt(10, 20)}</XmlTag>'))doesn't work. But, the error message I get is different from yours:
Tue Apr 09 13:19:29 CEST 2013:INFO:<XmlTag>No signature of method: static soapui.utils.MyUtils.randInt() is applicable for argument types: (java.lang.Integer, java.lang.Integer) values: [10, 20] Possible solutions: randInt(), randInt(java.lang.Object), randInt(java.lang.Object, java.lang.Object), wait()</XmlTag>
However, the line below:
log.info(context.expand('<XmlTag>${=soapui.utils.MyUtils.randInt(10,20)}</XmlTag>')) // :( return "<XmlTag>No such property: soapui for class: Script3</XmlTag>"works fine.
The explanation to this is that scripts written inside property expansions are evaluated as separate scripts (in a vacuum, you could say), and because of this the failing code snippet doesn't recognize that MyUtils has been imported, and thus fails.
Have you made sure that your script is located in the correct folder, set the scripts preferences correctly ("Script library" in "Preferences" -> "soapUI Pro"), and created the correct package structure (SoapUIHomeFolder/scripts/soapui/utils/MyUtils.groovy)?