如何使soapUI 附件路径相对?

发布于 2024-12-20 21:46:49 字数 193 浏览 1 评论 0原文

我正在使用soapUI 来测试HTTP 服务器。我需要发送一个多部分/表单数据请求,当我通过文件选择器并附加它时,该请求工作正常,但它将路径保存为绝对路径,并且我需要保存相对于我的测试文件的路径(但没有缓存在我的测试文件中)。我该怎么做?

仅供参考,我正在使用 SoapUI 4.0.1 免费版,如果我能弄清楚如何从中访问附件路径,我愿意使用常规编码步骤。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

〃温暖了心ぐ 2024-12-27 21:46:49

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

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 名称也会有所不同。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文