Eviware Forum

soapUI => soapUI => Topic started by: Wilco Schreurs on November 02, 2007, 09:32:02 am



Title: Saving attachments automatically
Post by: Wilco Schreurs on November 02, 2007, 09:32:02 am
I am testing a webservice that returns an attachment (MIME).
Is there a way to automatically save the retrieved attachment, preferably to a filename and folder that I can specify.
I know I can manually save attachments, but I would like to do that automatically, as part of a testsuite>testcase>teststep.
Maybe by using a particular assertion script?


Title: Re: Saving attachments automatically
Post by: omatzura on November 02, 2007, 10:05:37 am
Hi!

sure.. create a groovy script step after your request and use something like the following:

def testStep = testRunner.testCase.getTestStepByName( "request.." )
def response = testStep.testRequest.response

def outFile = new java.io.FileOutputStream( "myfile..")
def in = response.attachments[0].inputStream

com.eviware.soapui.support.Tools.writeAll( outFile,  in )


Hope I got that right.. :-)

regards!

/Ole
eviware.com