gpt4 book ai didi

java - 使用 Wiremock stub - WithBodyFile 位置不是 _files

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:36:54 24 4
gpt4 key购买 nike

Wiremock 文档指出,withBodyFile 中指定的文件位置应位于 src/test/resources/__files 中。我想在 src/test/resources/Testing_ABC/Testcase2/myfile.xml 中有文件。

有什么办法可以实现吗?我试过跟随,但它似乎不起作用!

stubFor(get(urlPathEqualTo("/abc")).willReturn
(aResponse().withHeader("Content-Type",
"text/xml; charset=utf-8").withHeader
("Content-Encoding",
"gzip")
.withBodyFile
("src/test/resources/Testing_ABC/Testcase2/myfile.xml)));

但是,当我将文件放入 src/test/resources/__files/myfile.xml 并相应地更改路径时,它工作正常。

我只是想知道我是否可以让 wiremock 在 __files 以外的资源中的其他目录中查找,以便在项目中拥有良好的资源结构。

最佳答案

我正在使用这个 Kotlin 配置类来自定义根目录。它仍然需要响应文件位于 __files 目录中。

@Configuration
class Config: WireMockConfigurationCustomizer {
override fun customize(config: WireMockConfiguration?) {
config!!.withRootDirectory("customer-client/src/test/resources")
}
}

@AutoConfigureWireMock

关于java - 使用 Wiremock stub - WithBodyFile 位置不是 _files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48203837/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com