Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-13607

Add selection of compare mode for Json assertion

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 4.2.3
    • Component/s: None
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

            People

            • Assignee:
              sdeleuze Sébastien Deleuze
              Reporter:
              Hronom Eugene Tenkaev
              Last updater:
              Stéphane Nicoll
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 4 weeks, 2 days ago