JsonAssert
Last updated
Was this helpful?
Last updated
Was this helpful?
– a library focused on understanding JSON data and writing complex tests using that data.
eg1:
The comparison mode LENIENT means that even if the actual JSON contains extended fields, the test will still pass:
As we can see, thereal_variable contains an additional field_zip_which is not present in the expected_String. Still, the test will pass.
This concept is useful in the application development. This means that our APIs can grow, returning additional fields as required, without breaking the existing tests.
The behavior mentioned in the previous sub-section can be easily changed by using the _STRICT _comparison mode:
eg2:
The compare mode can also be defined by using an overloaded method that takes boolean _instead of _JSONCompareMode _where _LENIENT = false _and _STRICT = true:
eg3: