Contributions
Re: call Script Library Method within dynamic property expansion
Hello, the point is that the ScriptLibrary (C:\Program Files\SmartBear\soapUI-Pro-4.5.1\bin\scripts\soapui\ used in groovy with soapui.*) is not imported within subscripts: context.expand('<XmlTag>${=soapui.utils.MyUtils.randInt(10,20)}</XmlTag>')) // return "<XmlTag>No such property: soapui for class: Script3</XmlTag>" Eval.me("soapui.utils.MyUtils.randInt(10,20)") // groovy.lang.MissingPropertyException: No such property soapui for class: Script1 Thus I don't think it is a groovy issue, it is more an issue how the script library is implemented. Or you can give me a hint how to import the ScriptLibrary to make the commands above up and running. What I want to achieve: - use own functions with in the XML's requests like <XmlTag>${=soapui.utils.MyUtils.randInt(10,20)}</XmlTag> - import dynamic libraries based on a property e.g. Property['Lib'] = "XYZ" myLibName = project.getPropertyValue('Lib') def myLib = evaluate(new soapui.libs."+myLibName+"(myLibName)") This should initialize an object of the class XYZ from the file "C:\Program Files\SmartBear\soapUI-Pro-4.5.1\bin\scripts\soapui\libs\XYZ.groovy" and handover the variable myLibName to the constructor. This is working fine with build in groovy mathods / classes but and within an groovy teststep not within own classes, why? Do I have to import a class or open a package? Regards Tino11 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.4KViews0likes0CommentsRe: call Script Library Method within dynamic property expansion
Hello, yes, the script library is set correctly and the package struckture is also okay. Following code is running fine: result = soapui.utils.MyUtils.randInt(10,20) log.info(result) I've the same problem with eval: string = "soapui.utils.MyUtils.randInt(10,20)" result = Eval.me(string) // groovy.lang.MissingPropertyException: No such property soapui for class: Script1 The interesting thing is following code is working find in a "Groovy Script TestStep" but NOT inside a method of me Library. Why???? string = "soapui.utils.MyUtils.randInt(10,20)" result = evaluate(string) I figured out that the evaluate() method is inside the groovy.lang.GroovyShell Class, but I couldn't find any way to use def shell= new groovy.lang.GroovyShell() result = shell.evaluate(string) // groovy.lang.MissingPropertyException: No such property soapui for class: Script1 If I try to create a new object (constructor is present) with the last solution (string = "new soapui.utils.MyUtils()") I get follwing Exception: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 1: unable to resolve class soapui.utils.MyUtils I've send many days in this topic! I really have no more Idea. Please Help!!!11 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.4KViews0likes0Commentscall Script Library Method within dynamic property expansion
Hello, how to call an own method with in the script library? One example method from my Script Library (based on this example) package soapui.utils class MyUtils { static def randInt(from = 1, to = 10) { return (int) from + (to * Math.random()) } } I want to expand some strings with a method of MyUtils: import soapui.utils.* log.info('<XmlTag>'+MyUtils.randInt(10,20)+'</XmlTag>') // :) return random value log.info('<XmlTag>'+soapui.utils.MyUtils.randInt(10,20)+'</XmlTag>') // :) return random value log.info(context.expand('<XmlTag>${=(int)10+290*(Math.random())}</XmlTag>')) // :) return random value log.info(context.expand('<XmlTag>${=java.util.UUID.randomUUID()}</XmlTag>')) // :) return a UUID log.info(context.expand('<XmlTag>${=MyUtils.randInt(10,20)}</XmlTag>')) // :( return "<XmlTag>No such property: MyUtils for class: Script2</XmlTag>" log.info(context.expand('<XmlTag>${=soapui.utils.MyUtils.randInt(10,20)}</XmlTag>')) // :( return "<XmlTag>No such property: soapui for class: Script3</XmlTag>" why the last two examples don't work? Regards Tino12 years agoPlace ReadyAPI QuestionsReadyAPI Questions6.1KViews0likes6CommentsRe: get calling TestCase at Groovy Script in called TestCase
Hello, yes, I know how to access the Properties but I don't know which test case ("my 1st TestCase" or "my 2nd TestCase") has calles the "get Values" test case. How I can get this information? Regards Tino12 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.8KViews0likes0CommentsRe: [res] shared Object / Variable (not Property) within a test
To save the string representation of the object inside a property is only one idea to get the same Object state back. But as I found in a similar thread this is not possible Another Idea is to save this object reference at a public variable within the testRunner object. Is there any similar method to achieve this? pseudo code for 1st TestStep: def myObject = new soapui.utils.myUtils( context, log) testRunner.setObjectReference("myObject", myObject) assert "1st TestStep" == myObject.context.testCase.getName() pseudo code for 2nd TestStep: myObject = testRunner.getObjectReference("myObject") assert "1st TestStep" == myObject.context.testCase.getName() If there is no similar method, it would be nice if you can create a feature request for the implementation of this Methods. Regards Tino12 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.3KViews0likes0Comments[res] shared Object / Variable (not Property) within a test
Hello, is there a possibility to share an Object or an Variable within a testRun? e.g. I have two groovy testSteps and I'm creating in the first step an Object of an own class: def myObject = new soapui.utils.myUtils( context, log) assert "1st TestStep" == myObject.context.testCase.getName() Now I need to access the same (!) Object within the second testStep: ???? assert "1st TestStep" == myObject.context.testCase.getName() In this case I get following Error message and the TestStep is failed: [tt:35su6o8z]ERROR:An error occured [No such property: myObject for class: Script3], see error log for details[/tt:35su6o8z] I don't want to create a new object: def myObject = new soapui.utils.myUtils( context, log) assert "2ndTestStep" == myObject.context.testCase.getName() If I try to save this Object at a Property I get only a string containing the reference: [tt:35su6o8z]soapui.utils.myUtils@2fb5a9d9[/tt:35su6o8z] Is it possible to use this string to fetch the initial created Object? Regards Tino12 years agoPlace ReadyAPI QuestionsReadyAPI Questions3.3KViews0likes4CommentsRe: set StepMessages for logging
Hello, could it be a possible solution to create an own Logging Class called myLog (in soapUI-Pro-4.5.1\bin\scripts\soapui\utils) and create an new Object with in the Project Event TestSuiteRunListener.beforeRun myLogHandler = new soapui.utils.myLog( context ) myLogHandler.info("Test Case " + testCase + " starting") But how to access this Object "myLogHandler" at within a groovy script. Is it possible to save with in the testRunner object an reference to the myLog Object? myLogHandler = ????? // reference to myLog Object for this testRun myLogHandler.info("Test Step" + testStep + " starting") Regards Tino12 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.1KViews0likes0CommentsRe: get calling TestCase at Groovy Script in called TestCase
Hello, sorry for the confusion, but I've had only one question I need the other direction: Within the script "Generic" - "get Values" - "get Test Data" I need to access a property from the initial calling TestCase ("my 1st TestCase" or "my 2nd TestCase"). Thus I can Imagine that the "testCase flow" or the "testStep flow" would be quite helpful, but I couldn't find any method providing a list of testCases / testSteps. Which logs you are referring to? Are these logs "Thread Save"? Because the Tests will run in parallel, if all TestCases will write the same logs it is impossible to get the correct logs (except there is anyRun ID). Regards Tino12 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.8KViews0likes0Comments