Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How set timeout for one test step in soapui?

Tags:

testing

soapui

I have create a test step in soapui. I need to set a long delay like 5 minutes for it. I mean that there is no delay between test steps, I have to wait a response only for one step. How can I do it?

like image 866
Cherry Avatar asked Oct 22 '14 03:10

Cherry


3 Answers

Set the Socket Timeout to 300000 milliseconds. SoapUI Documentation

like image 115
gnaanaa Avatar answered Nov 07 '22 13:11

gnaanaa


TestCase Options has a Socket timeout setting for that test. You cannot set this for only one step.

like image 39
SiKing Avatar answered Nov 07 '22 12:11

SiKing


As other answers says it's not possible to set the socket timeout for a TestStep, however you can do the trick with a TestStep and groovy TestStep. You can do it doing the follow steps:

  1. Create the TestStep inside your TestCase and disable it because you will run it from the groovy.
  2. Create a Groovy testStep which will change the global socket timeout before run the testStep and setting again the default value after execution using com.eviware.soapui.SoapUI class.

The groovy code you can use is showed below:

import com.eviware.soapui.SoapUI
import com.eviware.soapui.settings.HttpSettings
import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus

// get the settings 
def settings = SoapUI.getSettings();
// save the possible previous timeout
def bk_timeout = settings.getString(HttpSettings.SOCKET_TIMEOUT,"");
// set the new timeout... in your case 5 minutes in miliseconds
settings.setString(HttpSettings.SOCKET_TIMEOUT,"300000");
// save the new settings 
SoapUI.saveSettings();

// get the testStep by name
def testStep = testRunner.testCase.getTestStepByName('Test Request')
// run it
def result = testStep.run( testRunner, context )
if( result.status == TestStepStatus.OK )
{
    // ... if all ok    
}

// when finish set the timeout to default value again
settings.setString(HttpSettings.SOCKET_TIMEOUT, bk_timeout)
SoapUI.saveSettings()

Your testCase will looks like:

enter image description here

Note that If you want to check if change settings through groovy work as expected you can try modifying the properties and check if the preference SOAPUI file in $USER_HOME\soapui-settings.xml change (evidently to test it don't backup the original value again as in the sample :)).

like image 4
albciff Avatar answered Nov 07 '22 13:11

albciff