Forum Discussion
SmartBear_Suppo
12 years agoSmartBear Alumni (Retired)
Hi again,
Sorry for the delay... I also do not get notified when you answer![](http://community.smartbear.com/legacyfs/online/smilies/smiley.gif)
Well, I have tried the following scenario:
- Run a REST TestStep
- Run a Groovy TestStep with the following script:
- Run a DataSink TestStep to write the value of "response1" to a file.
NOTE: I added a question mark in the if condition resp?.statusCode == 200 so that if the response is null, as in when there's a timeout, Groovy will evaluate the expression to false.
I UNselected "Abort on Error" in the TestCase Options (click on the TestStep Editor's toolbox icon) to ensure the other test steps will always run regardless of whether the Test Request TestStep fails.
Everything worked as expected... when the Request fails with a SocketTimeoutException, The value of the property is set to "FAIL" by the Groovy script and then written to the data-sink. If the request succeeds, the response is written to the data-sink.
Could you please check if this scenario works for you? I believe this would solve your problem.
Best regards,
Renato
SmartBear Software
Sorry for the delay... I also do not get notified when you answer
![](http://community.smartbear.com/legacyfs/online/smilies/smiley.gif)
Well, I have tried the following scenario:
- Run a REST TestStep
- Run a Groovy TestStep with the following script:
def resp = testRunner.testCase.testSteps[ "Test Request" ].testRequest.response
def val = ( resp?.statusCode == 200 ) ? resp.responseContent : "FAIL"
testRunner.testCase.setPropertyValue( "response1", val )
- Run a DataSink TestStep to write the value of "response1" to a file.
NOTE: I added a question mark in the if condition resp?.statusCode == 200 so that if the response is null, as in when there's a timeout, Groovy will evaluate the expression to false.
I UNselected "Abort on Error" in the TestCase Options (click on the TestStep Editor's toolbox icon) to ensure the other test steps will always run regardless of whether the Test Request TestStep fails.
Everything worked as expected... when the Request fails with a SocketTimeoutException, The value of the property is set to "FAIL" by the Groovy script and then written to the data-sink. If the request succeeds, the response is written to the data-sink.
Could you please check if this scenario works for you? I believe this would solve your problem.
Best regards,
Renato
SmartBear Software
Related Content
- 12 years ago
- 7 years ago