问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/8490982/how-do-i-make-soapui-attachment-paths-relative