How to compare 2 JSON objects that contains array using Karate tool and feature files

天大地大妈咪最大 提交于 2019-11-27 05:39:53

This is classic over-engineering of tests. If someone has told you that "re-use" is needed for tests, please don't listen to that person.

You have two scenarios, one happy path and one negative path. I am providing how you should write the negative path here below, the rest is up to you.

Scenario: Change title of book in the non-existing book-record.
Given path '/book-record'
And header Authorization = 'Bearer ' + accessToken
And request {id: 00, name: 'Old Hello', config:[{username: 'qwe', password: 'tyu'},{username: 'abc', password: 'xyz'}]}
When method put
Then status 400
And response == {Error: 'not found', Message: 'The provided Book is not found.'} 

See how clean it is ? There is no need for "extreme" re-use in tests. If you still insist that you want a super-generic re-usable feature file that will handle ALL your edge cases, you are just causing trouble for yourself. See how un-readable your existing tests have become !!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!