Forum Discussion

srinivas_das_l's avatar
srinivas_das_l
Contributor
16 years ago

Create TestReport from the request and response in soupUI

Can any one tell me how to save Request and Response in a doc file .
what is the groovy script for that??

4 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    sure.. try the following after you have received a response:

    def testRequest = testRunner.testCase.testSteps["Request 1"].testRequest
    def out = new FileWriter( "out.txt" )

    out.println( testRequest.requestContent )
    out.println( testRequest.response.contentAsString )


    Hope this helps!

    regards,

    /Ole
    eviware.com
  • Thanx for the script.IT's really useful...but i want that to be done using a single script..like we can add that script to a testsuite and whenever we run that suite....all the Request and Response get printed in a text file with a single click...
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    well, that's not as easy, but still possible.. you would have to create a TestRunListener extension that intercepts all teststep executions, checks that the result is a WsdlTestRequestStepResult and logs the request/response accordingly. If you don't want this to apply to all teststeps run in soapUI, you could check for a TestCase property in the listener to enable/disable logging.. have a look at http://www.soapui.org/architecture/extensions.html to get going with soapUI extensions..

    makes sense?

    regards!

    /Ole
    eviware.com
  • Srinivas,

    Could you please let me know how you got on with ole's suggestion.

    I am interested in having this logging feature at testsuite/project level as well.

    Thanks,
    Bhuvan.