New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for strict JSON comparison in WebTestClient #27993
Conversation
@elgleidson Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@elgleidson Thank you for signing the Contributor License Agreement! |
It looks like the code examples for |
Done. |
Support for
expectedBody().json(<expected strict json>, true);
Part of the code base already has support - via
JsonExpectationsHelper
- butWebTestClient
has no method to use the strict version. The existing method useslenient
, which is not always desired.Example:
Let's say
/persons/1/
returns the following response:The following test works fine:
I'm just adding a new method so that we can use strict comparison when appropriate.
Example:
This test fails because the response has more fields than expected and we're using strict mode:
But the following test passes because we're expecting all fields: