如何验证 json 中的新字段而不会失败
How to verify new fields in json without fail
我有以下场景:
Given path /resource
And request data
When method POST
Then status 200
And match response contains resourceResponse
如果资源添加了一个新字段,我怎样才能准确无误地获取该信息?我的意思是我可以做 * match response == resourceResponse
但在这种情况下测试用例失败。
谢谢。
使用match contains
.
* def response1 = { foo: 'bar', hello: 'world' }
* def response2 = { foo: 'bar', hello: 'world', extra: 'blah' }
* match response2 contains response1
我有以下场景:
Given path /resource
And request data
When method POST
Then status 200
And match response contains resourceResponse
如果资源添加了一个新字段,我怎样才能准确无误地获取该信息?我的意思是我可以做 * match response == resourceResponse
但在这种情况下测试用例失败。
谢谢。
使用match contains
.
* def response1 = { foo: 'bar', hello: 'world' }
* def response2 = { foo: 'bar', hello: 'world', extra: 'blah' }
* match response2 contains response1