Ask a Question

Updating SLA time assertion for all the test cases in a project

Occasional Contributor

Updating SLA time assertion for all the test cases in a project



My current project structure look like this .. 



   -- Test suite 1

         -- 10 Test cases

   -- Test suite 2

          -- 20 Test cases




I had given assertion as 2sec for all the 250 test cases, I would like to know if I can change the assertion value for all test cases using a groovy script to 5sec instead of changing assertion value for each individual test case.




Champion Level 3

Groovy Approach

Note that though it is tested in a limited environment, have a copy of your original soapui project before running this script. This will modify the value of Response SLA assertion for most of the types which supports Response SLA i.e., HTTP, SOAP, REST and JDBC test requests



Add a Groovy Script step in the same project, in any test case. and copy the below and run the script:


Like it is mentioned earlier reply, it assigns a project level custom property RESPONSE_TIME_SLA as value of Response SLA assertion. So, you need to define the same project level property and put a value that is needed and save the project.


Of course, if you are executing the project using SOAPUI_HOME/bin/testrunner.bat/.sh utility, and the there is network latency you can still increase the value from the command-line itself (without even require to modify the value in project) by passing "-PRESPONSE_TIME_SLA=500" along with testrunner command line options.


You can also find it here


 * This script updates value of Response SLA assertion in the soapui project
 * with value mentioned for 'newSLA' variable below which 
 * currently assigns project level custom property call RESPONSE_TIME_SLA and
 * you need to define it with required value for the request steps of type
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep
import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep
import com.eviware.soapui.impl.wsdl.teststeps.JdbcRequestTestStep
import com.eviware.soapui.impl.wsdl.teststeps.HttpTestRequestStep
import com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.ResponseSLAAssertion
//update the new value as needed
def newSLA = '\${#Project#RESPONSE_TIME_SLA}'
//Get the project object
def project = context.testCase.testSuite.project

//Closure to update the Response SLA assertion value
def updateAssertionSLA = { assertion, sla ->
	if (assertion instanceof ResponseSLAAssertion) { "Found a request step assertion with Response SLA type, and updating its value"
//Actual script that traverse thru the project -> suite -> case -> step
project.testSuiteList.each { suite -> "Looking into test suite: ${}"
	suite.testCaseList.each { tCase -> "Looking into test case: ${}"
		tCase.testStepList.each { step -> "Looking into test step: ${}"
			if (step instanceof WsdlTestRequestStep 
				|| step instanceof RestTestRequestStep
				|| step instanceof JdbcRequestTestStep
				|| step instanceof HttpTestRequestStep) { "Found a request step of required type"
				def assertions = step.assertionList
				assertions.each{ updateAssertionSLA(it, newSLA) }





Thank you @rupert_anderson.

Occasional Contributor

Thank you Rupert and Rao. It works ... 

Champion Level 3

You can mark the message which you think helpful "Accept as Solution"


Do we have option to update the xpath for all assertions available in the project ?


My current xpath in all the test cases : //*:<api_name>_mResponse/<parent node>/<parent node_row>

I want to update :  //*:<api_name>_mResponse/*:<parent node>/*:<parent node_row>


Thanks a lot @nmrao and @rupert_anderson. This script really helped me in updating SLAs for over 900 test cases and it worked wonderfully.

Showing results for 
Search instead for 
Did you mean: