【发布时间】:2021-01-26 15:50:41
【问题描述】:
在使用存根在消费者端运行 Spring Contract 测试时。我首先收到了端点创建的响应,然后是发送给它的请求,然后是响应。
type1和type2都是枚举字段,其他字段都是字符串。
127.0.0.1 - POST /映射
Connection: [keep-alive]
User-Agent: [Apache-HttpClient/4.5.12 (Java/11.0.5)]
Host: [localhost:11291]
Content-Length: [834]
Content-Type: [text/plain; charset=UTF-8]
{
"id" : "7d0b6496-be88-43c0-891d-bdb8ef8ae033",
"request" : {
"url" : "/testEndpoint",
"method" : "PUT",
"headers" : {
"Content-Type" : {
"matches" : "application/json;charset=UTF-8.*"
}
},
"bodyPatterns" : [ {
"matchesJsonPath" : "$[?(@.['name'] == 'Test')]"
}, {
"matchesJsonPath" : "$[?(@.['type1'] == 'NONE')]"
}, {
"matchesJsonPath" : "$[?(@.['type2'] == 'NONE')]"
}, {
"matchesJsonPath" : "$[?(@.['description'] == null)]"
}, {
"matchesJsonPath" : "$[?(@.['comment1'] == null)]"
}, {
"matchesJsonPath" : "$[?(@.['comment2'] == null)]"
} ]
},
"response" : {
"status" : 201,
"transformers" : [ "response-template" ]
},
"uuid" : "7d0b6496-be88-43c0-891d-bdb8ef8ae033"
}
127.0.0.1 - PUT /testEndpoint
Connection: [keep-alive]
User-Agent: [Apache-HttpClient/4.5.12 (Java/11.0.5)]
Host: [localhost:11291]
Accept-Encoding: [gzip,deflate]
Content-Length: [117]
Content-Type: [application/json; charset=UTF-8]
{"name":"Test","type1":"NONE","type2":"NONE","description":null,"comment1":null,"comment2":null}
我得到的回应是:
Matched response definition:
(no response definition configured)
Response:
HTTP/1.1 404
(no headers)
【问题讨论】:
-
你使用的是最新的合约版本吗?
-
我也面临同样的问题@marcin 版本:verifierVersion、wiremock 版本和存根运行器版本 =3.0.3 有人可以帮我吗?或作者,如果您已经解决了,请与我们分享修复感谢您的帮助
标签: wiremock spring-cloud-contract