dmigarashi,
There are multiple ways to save the response. One of the way, like groovyguy suggested, is to use Script Assertion.
Below is for information benefit of others.
I was thinking for alternative ways and got strike with ways such as TearDown Script, Events etc.,
If I were to do the same, go for the Events because, Script in single place and gets fired automatically.
In the Events also, there are multiple available to handle this case as given below:
- SubmitListener.afterSubmit
- RequestFilter.afterRequest
- TestRunListener.afterStep
- MonitorListener.onMessageExchange
I would go with last one as I feel it is more appropriate based on the descriptions here in the documentation. However, I could not get that working.
So, trying with 1st one i.e., SubmitListener.afterSubmit Event.
Create a project level custom property LOCATION and provide directory name where the responses needs to be saved say C:/Users/apps/Data (Use / as path separator even on windows)
Here is the script that needs to go into above mentioned event:
https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/readyapi/events/SubmitListener_AfterSubmit/SaveResponse.groovy
EDIT:
Above script is refactored / moved to below location:
https://github.com/nmrao/readyAPIGroovyScripts/blob/master/groovy/events/SubmitListener/afterSubmit/SaveResponse.groovy