Reputation: 4334
I want to know what is the correct way of setting up a folder directory within SOAPUI. Should I use setup scripts within each testcase or testsuite level or should they be setup within a groovy script step whenever required?
Currently I decided to use the groovy script method only because if I use it in a setup script, it means I have to run the setup script first to get the folder directory before I can run the test case that contains a script assertion.
Below is an example of my folder directory set up in a groovy script (called test script):
def date = new Date()
def folderTime = date.format("yyyy-MM-dd HH-mm-ss")
//Create a folder directory for the responses
RootResultFolder = dataFolder + "\\Log Smoke Test Data" + "\\xxx" + "\\xxx - " + folderTime + "\\"
CreateResultFolder = new File(RootResultFolder)
CreateResultFolder.mkdir()
...
context.setProperty( "RootResultFolder", RootResultFolder )
Below is my script assertion within a test step that uses the above folder directory:
def date = new Date().format("yyyy-MM-dd")
def time = new Date().format("HH.mm.ss")
def dataFolder = context.getProperty("RootResultFolder")
def fileName = xxx+ ".txt"
def rootFolder = dataFolder + fileName
def logFile = new File(rootFolder)
logFile.write "TEXT: " + xxx + "\n\n" +
JsonOutput.prettyPrint
Thank you
Upvotes: 11
Views: 1720
Reputation: 5585
I suggest you place them relative to project with the following code
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
// define location relative to SOAPUI project.
String projectPath = groovyUtils.projectPath + "/destination/"
context.setProperty( "RootResultFolder", projectPath)
Upvotes: 4