question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Introduce NON_EXTENSIBLE JSON assertion support in spring-test

See original GitHub issue

Please add a method for JSONCompareMode.NON_EXTENSIBLE to JsonExpectationsHelper in spring-test.

Because: mostly you want to assert that both requests contain exactly the same content and the same fields. But order of elements usually does not matter, as json is nothing other than a HashMap.

That’s simply not possible to assert as of now.

NON_EXTENSIBLE is the correct mode in that case.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AviranBaccommented, Oct 1, 2022

What about adding your own spring enum type that resembles to JSONCompareMode? You’re then free of api changes in future with json(String, SpringJsonCompareMode), but give the user the ability to directly chose the desired mode.

Some of them can then delegate to existing json(String, true) and json(String, false), while another delegates explicit to the NON_EXTENSIBLE?

Hey, I strongly suggest this idea since I also found myself looking for a NON_EXTENSIBLE solution in your API but there isn’t an implementation for it at the moment. I hope you can reconsider and reopen this issue.

1reaction
membersoundcommented, May 15, 2020

What about adding your own spring enum type that resembles to JSONCompareMode? You’re then free of api changes in future with json(String, SpringJsonCompareMode), but give the user the ability to directly chose the desired mode.

Some of them can then delegate to existing json(String, true) and json(String, false), while another delegates explicit to the NON_EXTENSIBLE?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction to JSONassert - Baeldung
Learn how to use a JSONassert library, focused on understanding JSON data, by writing complex JUnit tests.
Read more >
44. Testing - Spring
Spring Test & Spring Boot Test: Utilities and integration test support for Spring Boot applications. ... JSONassert: An assertion library for JSON.
Read more >
Karate | Test Automation Made Simple.
This demonstrates a Java Maven + JUnit 5 project set up to test a Spring Boot app. Naming Conventions. Since these are tests...
Read more >
2020 Peilun Zhang - Darko Marinov's Research Group at UIUC
identify a number of tests that fail due to test assertions comparing JSON strings: the serialization of Java objects into JSON strings can...
Read more >
org.skyscreamer.jsonassert Enum JSONCompareMode
These different modes define different behavior for the comparison of JSON for testing. Each mode encapsulates two underlying behaviors: extensibility and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found