How do I make soapUI attachment paths relative?

烂漫一生 提交于 2020-01-02 05:20:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!