How set timeout for one test step in soapui?

40,476

Solution 1

Set the Socket Timeout to 300000 milliseconds. SoapUI Documentation

Solution 2

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

Solution 3

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 :)).

Solution 4

I have found a way to set the testCase socket timeout.

In the setup script of the testCase use the following code:

testRunner.testCase.settings.setString("HttpSettings@socket_timeout","10000")

All steps inside of the testCase will be affected by this value.

The global SOCKET_TIMEOUT value is not affected by this.

Share:
40,476
Cherry
Author by

Cherry

Updated on March 03, 2020

Comments

  • Cherry
    Cherry about 4 years

    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?

  • Cherry
    Cherry over 9 years
    it applt for all request/responses in soapui but I want only for one test
  • Cherry
    Cherry over 9 years
    which will change the global socket timeout - it seems that it affects for all soapui project. I mean that if there are another tests are running in parallel, they will "see" modified global timeout. For example when several test cases contains that code they can set global timeout synchronically and for several of them it can be smaller than needed. May it is better to set TestCase timeout as SiKing suggested?
  • albciff
    albciff over 9 years
    In your question there is no requirement about running test in parallel this is why I show you a possible workaround to do it with global properties. However if there is a socket timeout in testCase level I think that make a similar groovy script changing this property could be possible. I check it, if exists I will update my answer.
  • David García González
    David García González over 8 years
    If the timeout is not set. What is the default timeout?
  • gnaanaa
    gnaanaa about 8 years
    60 seconds is the default value.
  • Zeeshan
    Zeeshan about 8 years
    Thank you, I was able to set timeout for a test case :)
  • Dinesh Rajan
    Dinesh Rajan almost 8 years
    You can set 0 for no timeout