Forum Discussion

LZhang's avatar
LZhang
Frequent Contributor
18 years ago

relative path for input/output files

Hi, Ole:

I use external txt files for Datasource input as well as I output my xml request/response to external files.  One issue I saw in testing
was if other people want to run my soapUI project files, they will run into error since they might have different directory path.

Can you add a “testDir” option somewhere in preference that way, for example, we can set testDir = C:\Workspace\QA\Automation
and then in my datasource configuration, leave a field for the user to set up the rest of the path, in this case,
File: TestDir\SoapUI\Phase2.5\myProject.xml

Or we can call TestDir in our groovy script
def msg=context.getProperty("GetDVRDevices_AfterUnlink#Response")
new File(context.testCase.testSuite.project.testDir+ "GetDVRDevices_AfterUnlinkRS" + dateFormat.format(date) + ".txt").write(msg2)

Or do you have a better suggestion?

I am concern about how other people can call my input and output files correctly if using relative path.


Thanks,
Li
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Li,

    currently what you can do is use the projectPath property in groovyUtils to create a path relative to the project file. If you for example have a "testdata" folder next to your project file containing your data, you can use

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    log.info( groovyUtils.projectPath )

    def msg=context.getProperty("GetDVRDevices_AfterUnlink#Response")

    new File(groovyUtils.projectPath + "\\testdata\\GetDVRDevices_AfterUnlinkRS" + dateFormat.format(date) + ".txt").write(msg2)

    Your testDir is a good idea, We'll find some way to support the concept!

    regards!

    /Ole
    eviware.com