Groovy returns No such property: testRunner for class when using java class
Hi,
in groovy if i use a java class, it returns
groovy.lang.MissingPropertyException: No such property:tesRunner for class: Simple
here is the code:
class Simple{
public void main(String[]args){
def x = ("test")
//log.info x
testRunner.testCase.testSuite.project.setPropertyValue("x",x)
}
}
How should we declare testRunner in this class?
It happens same thing with log.info
Hi _ivanovich_
It's a bit tricky to deal with both groovy and SoapUI in this case.
Here is what I can propose to you.
So at first you can create a TestSuite and a TestCase to store your groovy classes.
For example this one:
context.setProperty("simpleClass", new Simple()) class Simple{ public void main(String[]args){} public void setProjectProperty(propertyName, propertyValue, testRunner) { testRunner.testCase.testSuite.project.setPropertyValue(propertyName,propertyValue) } }
And then inside your script you can call your class this way:
def currentProject = testRunner.testCase.testSuite.project currentProject.testSuites["TestSuite"].testCases["TestCase"].testSteps["Simple Class"].run(testRunner,context) def simple = context.simpleClass simple.setProjectProperty("TEST", "testing groovy class", testRunner)
Keep in mind you won't be able to use things like the log.info command inside your class 😉
Hope this helps.
David.