Forum Discussion

annika's avatar
annika
Occasional Contributor
13 years ago

using closures defined in a testSuite in a Groovyteststep

Hi,
I want to define one GroovyClosure or Method and use them in many Groovyteststeps. How can I do that?

2 Replies

  • annika's avatar
    annika
    Occasional Contributor
    Hi,
    I solved my Problem Like this:
    I created a Propertyvalue in the Testsuite. It's a closure in a String.

    add='{a,b-> a+b}'
    testSuite.addProperty('add')
    testSuite.setPropertyValue('add',add)

    And it can be used in a Groovyteststep like this

    sh = new GroovyShell()
    closure = sh.evaluate(context.expand('${#TestSuite#add}'))
    return closure('ha','lo')

    But there has to be a better Solution. Can I use something like context.createStatement() in the free Version of SoapUI? and How?
  • annika's avatar
    annika
    Occasional Contributor
    hm... don't know if it helps but somewhere in the Forum rules I read something like I should write "HELP ME" to get replies faster. Hope I got this right. my English is not so good. I know, you allready noticed.