cancel
Showing results for 
Search instead for 
Did you mean: 

Saving request and response

SOLVED
pankajmalinda
Occasional Contributor

Saving request and response

 

SOAP UI Screenshot.PNGI want to save request and response of all the tests(Failed/Passed) from my Automation test suite.

The folder location should be like ProjectName-->TestSuiteName(Multiple folders for multiple test suite)-->TestCaseName(Multiple folder for multiple test cases)- a single .xml file containg request and response of test steps (Multiple files for multiple test steps).

1 ACCEPTED SOLUTION

Accepted Solutions
richie
Community Hero

Re: Saving request and response

Hi @pankajmalinda

 

There's a groovy event handler that does this quite nicely - the following script will record the request and response for each test step as well as the pass/fail result for every test step, in every test case, in every test suite in a project.

 

The event handler is 'TestRunListener.AfterStep'

 

The script is as below:  

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 = 'C:/SoapUI Projects/TS0.1/TestEvidence/'+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()

 

I think this is brilliant - can't claim it was my code - I found it somewhere on soapui.org - but it records everything!

 

I use it as a way to capture my test evidence

 

Hope this helps,

 

richie

 

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

View solution in original post

2 REPLIES 2
msiadak
Community Hero

Re: Saving request and response

Are you familiar with groovy scripting? That might be the easiest way to accomplish this.




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
richie
Community Hero

Re: Saving request and response

Hi @pankajmalinda

 

There's a groovy event handler that does this quite nicely - the following script will record the request and response for each test step as well as the pass/fail result for every test step, in every test case, in every test suite in a project.

 

The event handler is 'TestRunListener.AfterStep'

 

The script is as below:  

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 = 'C:/SoapUI Projects/TS0.1/TestEvidence/'+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()

 

I think this is brilliant - can't claim it was my code - I found it somewhere on soapui.org - but it records everything!

 

I use it as a way to capture my test evidence

 

Hope this helps,

 

richie

 

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors