[英]Ignore fields to map in response from controller in Contract Tests
As I'm only interested in checking some of the values from the response for my Contract Test, I want to leave out those fields that are not important to me.因为我只对检查我的合同测试响应中的一些值感兴趣,所以我想忽略那些对我不重要的字段。 Thing is that when I run the test, generated test file checks if body defined in the test.groovy file is identical to the one generated from controller.
问题是,当我运行测试时,生成的测试文件会检查test.groovy文件中定义的主体是否与控制器生成的主体相同。 So, my question is if there's a way to just assert those values that I'm interested in.
所以,我的问题是是否有一种方法可以断言我感兴趣的那些价值观。
test.groovy测试.groovy
Contract.make {
request {
method 'GET'
urlPath('/api/node') {
queryParameters {
parameter('number', '123')
parameter('size', '1')
parameter('status', 'ACTIVE')
}
}
headers {
header("key", "someKey")
}
}
response {
status 200
headers {
contentType applicationJson()
}
body("""
"content":[
{
"id": "123456",
"status":"ACTIVE",
"details":[
{
"object":{
"id":"ccId",
"codeOne":"1",
"codeTwo":"2",
"codeThree":"3",
"_links":{
"self":{
"href":"https://url.com"
},
"style":{
"href":"https://universal-url.com"
},
"universalStyle":{
"href":"https://universal-style-v1-url.com"
}
}
}
"code":null
}
]
This is the error I'm getting这是我得到的错误
org.junit.ComparisonFailure: expected:<"[content]"> but was:
<"[{"links":[
{"rel":"first","href":"http://localhost/api/node?number=123&status=ACTIVE&page=0&size=1"},
{"rel":"prev","href":"http://localhost/api/node?number=123&status=ACTIVE&page=0&size=1"},
{"rel":"self","href":"http://localhost/api/node?number=123&size=1&status=ACTIVE"},
{"rel":"last","href":"http://localhost/api/node?number=123&status=ACTIVE&page=1&size=1"}],
"content":[{"id":"123456",...
In this case, I don't want to verify any related to "links" array.在这种情况下,我不想验证任何与“链接”数组相关的内容。 Is there any configuration I can use in order to bypass it?
我可以使用任何配置来绕过它吗?
只是不要将它们放在响应中,它们不会被生成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.