Skip to content

Add selection of compare mode for Json assertion [SPR-13607] #18185

@spring-projects-issues

Description

@spring-projects-issues

Eugene Tenkaev opened SPR-13607 and commented

Greetings everyone!

spring-test for comparing json use external library called jsonassert.

This lib has several modes of comparing json:

  • STRICT - Strict checking. Not extensible, and strict array ordering.
  • LENIENT - Lenient checking. Extensible, and non-strict array ordering.
  • NON_EXTENSIBLE - Non-extensible checking. Not extensible, and non-strict array ordering.
  • STRICT_ORDER - Strict order checking. Extensible, and strict array ordering.

By default spring-test in method org.springframework.test.web.servlet.result.ContentResultMatchers#json use this library in mode LENIENT.

This mode is not strict enough. In situation when in your json new field has added, your tests not failed, so app that use API with this json can crash when try to deserialize this in some POJO!

Also this is not acceptable, when you want compare json in other useful modes, for example NON_EXTENSIBLE.

So it would be great if developers can specify which mode to use in comparisons.


Referenced from: pull request #897, and commits 1d60a6a

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions