Forum Discussion
SmartBear_Suppo
12 years agoSmartBear Alumni (Retired)
If the assertion fails, then the next test-step will not run, ensuring that the incorrect value is not written to your data-sink.
If what you want, instead, is to ensure you write an error into the data-sink when the response code is not 200, you may write a simple Groovy script testStep as follows:
This will set the value of property "response1" in the TestCase to either "FAIL" or the actual response returned by the server.
To write this property to your data-sink, add a data-sink property with the following value, without quotes: "${#TestCase#response1}"
Let me know if this helped,
Renato Athaydes
SmartBear Software
If what you want, instead, is to ensure you write an error into the data-sink when the response code is not 200, you may write a simple Groovy script testStep as follows:
def resp = testRunner.testCase.testSteps[ "Test Request" ].testRequest.response
def val = ( resp.statusCode == 200 ) ? resp.responseContent : "FAIL"
testRunner.testCase.setPropertyValue( "response1", val )
This will set the value of property "response1" in the TestCase to either "FAIL" or the actual response returned by the server.
To write this property to your data-sink, add a data-sink property with the following value, without quotes: "${#TestCase#response1}"
Let me know if this helped,
Renato Athaydes
SmartBear Software
Related Content
- 12 years ago
- 7 years ago
Recent Discussions
- 6 days ago
- 10 days ago