Need help to add tear down script in all the testcases
we have around 3000 testcases. we are planning to add the tear script in all the testcases. Is there a script that can update in all the testcases tear down.
It is difficult to add tear-down script for those many cases manually. However, It is possible to add the tear down script automatically with a simple script as below.
NOTE: The script will add the tear-down for all the tests cases in the project. i.e,, it will modify the project. So take a backup of your project before running the below script.
How to execute the script?
a. Make sure you have closed the soapui project for which you want to add the tear-down script.
b. Create an empty project -> suite -> test case -> groovy script and add the below content in there.
c. The groovy script need the following files as input.
i. SoapUi project file
ii. Create a file with the desired tear-down script which needs to be copied to all the tests.
And provide/update the above two file paths in the script.
import com.eviware.soapui.impl.wsdl.WsdlProject //EDIT below two paths def soapUIProject = '/home/apps/Documents/Project-5-soapui-project.xml' def tearDown = '/home/apps/Documents/TeardownScript.txt' //Do not edit beyond this def tearDownScript = new File(tearDown).text def project = new WsdlProject(soapUIProject) project.testSuiteList.each { suite -> suite.testCaseList.each { caze -> caze.setTearDownScript(tearDownScript) } } project.save() log.info 'Completed updating the project' + soapUIProject
As the your project is big, it might take a while to add the same to the project.
Once it is done, you may try opening your actual project and check.