Forum Discussion

smartTest's avatar
smartTest
Contributor
13 years ago

[Resolved] Saving all TestStep's results into files

Hiya

I found the above on your Tips & Tricks page but can't quite get it to work, not very good a scripting unfortunately. The code I have set in Events under TestRunListener.afterStep is:

filePath = 'c:/SoapUi Reports/'
fos = new FileOutputStream( filePath + testStepResult.testStep.label + '.txt', true )
pw = new PrintWriter( fos )
testStepResult.writeTo( pw )
pw.close()
fos.close()

Its creating files for reach test step, but isn't populating it with anything, yet the Tips & Tricks say it should "...save the result (request data, response data, response time, etc.) of every executed TestStep in a Project."

Can you let me know how I can update the script to provide this detail.
Thanks
Diana

2 Replies

  • Howdy!

    Hmm, this should work. To verify exactly what's working and what's not, could you try to do the same thing, but replacing this:

    testStepResult.writeTo( pw )


    with this:

    pw.println( 'Testing, testing... one, two, one, two!' )


    ...and then see if the files are empty or not?


    Regards

    Henrik
    SmartBear Software
  • Hi Henrik

    Thanks for replying.

    I tried your idea with the new snippet and it seemed that the code worked in some scenarios but not in others. I realised it must have something to do with the test steps/case themselves so went back to basics and found the issue. The naming convention i had used for the test steps in one was different to the other and I saw the non-working steps contained a colon, something that will not work in a file name. Since amending all the tast step names I have been able to store the results.

    It never occured to me it could be so simple to fix - hope this helps anyone else in the same position.

    Thanks again
    Diana