Through a groovy teststep in soapUI i want all request and response files to be stored in a local directory with system date.
The groovy teststep in soapUI:
More useful if we should save an error in Response:
import com.eviware.soapui.support.XmlHolder
import java.text.MessageFormat
import org.apache.commons.lang.ObjectUtils
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def retrieve = groovyUtils.getXmlHolder("MyTestRequest#Response" )
if (!ObjectUtils.equals(retrieve.getNodeValue("//*:xpath"), "string")){
def currentTime = System.currentTimeMillis()
def fullFilePath = context.expand('${projectDir}') + File.separator + "Fail-"+currentTime+".xml"
def reportFile = new File(fullFilePath)
if (!reportFile.exists())
{
reportFile.createNewFile()
reportFile.append((Object)retrieve.getPrettyXml(), 'UTF-8')
}
}