Jared
Jared

Reputation: 1897

How do I make soapUI attachment paths relative?

I'm using soapUI to test an HTTP server. I need to send a multipart/form-data request, and the request works fine when I go through the file chooser and attach it, but it's saving the path as an absolute path, and I need to save a path relative to my test file (but not cached IN my test file). How can I do this?

FYI, I'm using SoapUI 4.0.1 free edition and I am willing to using a groovy coding step if I could figure out how to access the attachment path from it.

Upvotes: 4

Views: 1889

Answers (1)

Jared
Jared

Reputation: 1897

OK, I solved this by adding a groovy coding step. Took a while to navigate the API, so documenting it here for others.

testFile = new File(testRunner.testCase.testSuite.project.getPath())
resourceDir = new File(testFile.getParentFile().getParentFile(), "resources")
myFile = new File(resourceDir,"MyFileToAttach.txt")
testRunner.testCase.testSteps["My Post step"].getHttpRequest().attachFile(myFile, true)

Obviously, the navigation to your file via getParentFile or to subdirectories may be different, and your testStep names will be different.

Upvotes: 3

Related Questions