Introduce NON_EXTENSIBLE JSON assertion support in spring-test
See original GitHub issuePlease 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:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
What about adding your own spring enum type that resembles to
JSONCompareMode
? You’re then free of api changes in future withjson(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)
andjson(String, false)
, while another delegates explicit to theNON_EXTENSIBLE
?