问题
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?
回答1:
Set the Socket Timeout to 300000 milliseconds. SoapUI Documentation
回答2:
TestCase Options has a Socket timeout setting for that test. You cannot set this for only one step.
回答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:
- Create the
TestStepinside yourTestCaseand disable it because you will run it from the groovy. - Create a
Groovy testStepwhich will change the global socket timeout before run thetestStepand 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:
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 :)).
回答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.
来源:https://stackoverflow.com/questions/26500006/how-set-timeout-for-one-test-step-in-soapui