Forum Discussion

Buschfunk's avatar
Buschfunk
Frequent Contributor
14 years ago

Text templates

Hello,

Another feature request

Scenario
A test suite contains n test cases which all call an identical Groovy script (~ 40 lines). Currently this means keeping n copies of this script, which makes changes very annoying.

Feature request
Similar to a code template it would be useful if the script was written and stored in soapUI only once. In each test case the Groovy test step contains something like project.getTextTemplate("myScript") whereas myScript would contain the actual Groovy script.

I could copy the script to a project property but this would make it hard to read and edit.

Sincerely,
Robert
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    To address this need now, why not create an external script file with a function that takes the 3 variables available in a Groovy script (log, context, testRunner), put your code there, then just call the function in each Groovy step?

    Example script file MyFuncs.groovy:

    class MyFuncs {
    def myFunc(log, context, testRunner) {
    log.info "Hello!"
    }
    }


    Groovy step:

    new MyFuncs().myFunc( log, context, testRunner )
  • SoapUI has a script library that seem to be what you are looking for. Read more here.

    Regards

    Henrik
    SmartBear Software