Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Overview
The PR proposes a fix for the following tests -
com.jsoniter.extra.TestPreciseFloat#test_indirect_encode
com.jsoniter.output.TestGson#test_serializeNulls
com.jsoniter.output.TestObject#test_omit_default
com.jsoniter.output.TestObject#test_omit_null
com.jsoniter.output.TestNested#test_map_of_objects
com.jsoniter.output.TestNested#test_object_of_array
com.jsoniter.output.TestGenerics#test_wildcard
com.jsoniter.output.TestObject#test_indention
Build Project
Problem
This flakiness was identified by the nondex tool created by the researchers of UIUC. The above eight tests fail when run on the nondex tool.
The eight tests, although varied in notion of what is being tested are flaky for the same reason. A json with more than one field is being serialised and being checked with
assertEquals
. When the json is being serialised, the order is not maintained andassertEquals
fails at times when it is different from the true order. This does not occur with json with one element since order is constant.java/src/test/java/com/jsoniter/output/TestGenerics.java
Lines 47 to 57 in 6925cf4
This means for the test above, the json that is being serilaised is -
The serialized output can be either
This change in ordering presents itself in different instances in the above eight tests.
Fix:
The proposed fix to use
JSONAssert.assertEquals
fromorg.skyscreamer.jsonassert.JSONAssert
package which checks the structure of the JSON in the equality and not focus on the order of the field. This provides more granularity and accuracy of how we check JSON value equalities.