Simple script to batch edit multiple groovy scripts
Question
How to batch edit multiple groovy scripts? Here is my solution.
Answer
import com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep
def testSuite = 'testsuitename'
String textToSearch = """text"""
def replacementText = """text"""
def tSuite = context.testCase.testSuite.project.testSuites[testSuite]
def testcases = tSuite.testCaseList.toArray()
testcases.each() {Case ->
for( testSteps in Case.testStepList ) {
if( testSteps instanceof WsdlGroovyScriptTestStep && testSteps.getScript().contains(textToSearch)) {
log.info(Case.getName().toString() + " - " + testSteps.getScript().toString())
String newString = testSteps.getScript().toString().replace(textToSearch, replacementText)
testSteps.setScript(newString)
}
}
}
Updated 4 years ago
Version 1.0