Reputation: 4435
I'd like to externalize my groovy scripts to a file. Instead of
<con:testStep type="groovy" name="Init" id="ba3d9999-6cf7-4697-ac71-2472a61f16fc">
<con:settings/>
<con:config>
<script>log.info "[ isr::CallbackController::Init ] "</script>
</con:config>
</con:testStep>
I'd prefer something like this:
<con:testStep type="groovy" name="Init" id="ba3d9999-6cf7-4697-ac71-2472a61f16fc">
<con:settings/>
<con:config>
<script file="path/to/my.groovy"/>
</con:config>
</con:testStep>
Upvotes: 0
Views: 57
Reputation: 18507
I think that this is not currently supported in SOAPUI, maybe you can add a feature request to it :).
However in the meantime maybe the following tricky workaround could be useful for you.
I purpose you to create a groovy script testStep which reads your script from a file, dynamically create a groovy testStep, sets the script with the file content, execute this new dynamic created testStep and finally remove it in order that it can be run it multiple times. See the follow script:
import com.eviware.soapui.impl.wsdl.teststeps.registry.GroovyScriptStepFactory
// read the file with your script
File f = new File('path/to/my.groovy')
def tc = testRunner.testCase
// create a empty groovy testStep in the current testCase
def groovyTS = tc.addTestStep( GroovyScriptStepFactory.GROOVY_TYPE, "Groovy testStep dinamic" )
// set the file script as a content
groovyTS.properties["script"].value = f.text
// run the the created testStep with your script
groovyTS.run(testRunner,context)
// once runned delete it
tc.removeTestStep(groovyTS)
As @Rao note in the comments, maybe an easy way to do so it's simply use evaluate
in the groovy script testStep as:
evaluate(new File('path/to/my.groovy'))
At first I avoid this option thinking on possible problems with context variables like testRunner
, context
, log
... and I use the option to create groovy testStep to keep it as similar as possible to the SOAPUI way. However using evaluate
seems a really nice and easier workaround.
Upvotes: 2