Forum Discussion

richie's avatar
richie
Community Hero
8 years ago
Solved

Transaction Logging - Tip & Tricks 8.1 Script records all teststeps EXCEPT one!!??!?!????

Hey!

 

There's been several posts relating to recording the results of all the steps within your test case/suite/project.  Tips&Tricks section 8.1 lists a small groovy script to output the results of each step in your test case

 

filePath = 'c:/users/henrik/soapUI-results/'
fos = new FileOutputStream( filePath + testStepResult.testStep.label + '.txt', true )
pw = new PrintWriter( fos )
testStepResult.writeTo( pw )
pw.close()
fos.close()

 

This was augmented when someone wanted to organise the results via a directory structure representing Project/Suite/TestCase etc.

 

HOWEVER - the script works great -both versions - but it doesn't appear to record anything for one of my steps.

 

Datasource
POST REST request
PropertyTransfer
GET REST request
DataLoop

The script doesn't record anything for my POST REST request step.  It records everything for the other steps - but it doesnt record ANYTHING for my POST step.

 

This is totally boggling me - would anyone have any ideas?

 

My Test case works fine - the POST step is executed just as the other steps are......there's just nothing being recorded for that particular step!

 

????

 

richie!

 

  • yet again - I'm an idiot.

     

    The script wasn't creating a file for the one test step because the test step name was:

     

    'create/update user request'

     

    spot the issue?  yeah - I didn't!

     

    The script won't create a file for any step that has an oblique (/) character in there!

     

    so obvious when you think about it...... so yet again I've answered my own question - sorry for wasting anyone's time!

     

    richie

9 Replies

  • richie's avatar
    richie
    Community Hero

    yet again - I'm an idiot.

     

    The script wasn't creating a file for the one test step because the test step name was:

     

    'create/update user request'

     

    spot the issue?  yeah - I didn't!

     

    The script won't create a file for any step that has an oblique (/) character in there!

     

    so obvious when you think about it...... so yet again I've answered my own question - sorry for wasting anyone's time!

     

    richie

    • groovyguy's avatar
      groovyguy
      Champion Level 1

      That's one of those issues that is so stupidly simple that you can catch yourself on it until you take a break and come back. Thanks for the update!

      • richie's avatar
        richie
        Community Hero

        Hey!

         

        quick question for the groovy scripters out there.

        the latest version of the script records everything and splits it out into a hierarchical structure on the drive is as follows:

         

        def pName = context.currentStep.testCase.testSuite.project.name //get project name
        def pDate = new Date().format( 'yyyyMMdd' )//get current date
        def sDate = pDate.toString()//convert date to string
        def pTestSuite = context.currentStep.testCase.testSuite.name//get TestSuite name
        def pTestCase = context.currentStep.testCase.name//get TestCase name
        def filePath = 'D:/Donor Marketing/SoapUI/SOAPUI LOGGING SCRIPT/soapUI-results/'+pName+'_'+sDate+'/'+pTestSuite+'/'+pTestCase+'/'//compose the folder path
        
        File file = new File(filePath)
        if (!file.exists()) file.mkdirs()//create the destination folder
        
        fos = new FileOutputStream(filePath+ testStepResult.testStep.label + '.txt', true)
        pw = new PrintWriter( fos )
        testStepResult.writeTo( pw )
        pw.close()
        fos.close()

        HOWEVER - I am using this in a datalooped parameterized test case which is sourcing a hundred records from a hundred individual testdata files.

        The request/response capturing is great for getting the QA Team off my back, however - the requests/responses are listed sequentially but without any identifiers indicating which instance of test case the results/responses relate to. The only thing I can do at the moment is count through the results in the particular file (associated to the test step) to find the record's results/responses I need.

        I was wondering if anyone had found a way to split out the request/responses (within the test step's output file) - even if just adding a simple number to indicate which result/response was for which instance of test (e.g. so I can tell which testdata file caused the request/response details captured in the file).

        hanks to any and all,

        richie