如何使soapUI附件路径相对? [英] How do I make soapUI attachment paths relative?

查看:222
本文介绍了如何使soapUI附件路径相对?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用soapUI测试HTTP服务器.我需要发送一个multipart/form-data请求,当我通过文件选择器并将其附加时,该请求可以正常工作,但是它将路径保存为绝对路径,并且需要保存相对于我的测试文件的路径(但未缓存在我的测试文件中).我该怎么办?

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?

仅供参考,我使用的是SoapUI 4.0.1免费版,如果我想知道如何从中访问附件路径,我愿意采用常规的编码步骤.

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.

推荐答案

好的,我通过添加一个常规的编码步骤解决了这个问题.花了一些时间浏览API,因此在这里为其他人编写文档.

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)

很明显,通过getParentFile到文件或子目录的导航可能会有所不同,并且testStep的名称也会有所不同.

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

这篇关于如何使soapUI附件路径相对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆