Forum Discussion

anuvinut's avatar
14 years ago

How to save responce to a text file while running datasource

Hello,
I am trying to create a test suite for my data driven testing for a web service. I added all my test data to datasource and parametrized in my request. When I run the test it runs successfully but the results are not saved in the message viewer. It is showing only for the last 5 iterations or so. Is there any option that I need to select to keep the data or save the response to text file while running the testsuite.
Thanks
Vinny

1 Reply

  • Aaronliu's avatar
    Aaronliu
    Frequent Contributor
    Hi anuvinut,

    if you want to save data to a text file, you can reference the code fragment below

    import com.eviware.soapui.support.XmlHolder

    def stepName = "TestStepName" // to change the step name depending on your step name
    def testStep = testRunner.testCase.getTestStepByName(stepName)
    def testreq = testStep.testRequest //request

    def folderName = "C:/Response"
    def createFolder = new File(folderName)
    createFolder.mkdirs()
    def date = new Date()
    def xHolder = new XmlHolder(testreq.response.contentAsString)
    def f = new File(folderName+'/'+date.getTime()+'.txt')
    f.write(xHolder.prettyXml)
    xHolder.clear()


    (thanks for Pradeep Bishnoi provided)

    Thanks,
    Aaron