Fixed test failure(test4) by comparing maps instead of json. #447
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.
Created this PR to fix 1 flaky test - test4
How were these test identified as flaky?
This test was identified as flaky by using an open-source research tool named NonDex which is responsible for finding and diagnosing non-deterministic runtime exceptions in Java programs.
What was the error?
When the test convert childBean to json string
String json = JsonKit.toString(childBean);
, the order of keys (i.e. repeatField, childField, superField) is not guaranteed. Thus, when we compare this String variable 'json' directly to hardcoded string"{\"repeatField\":\"sss\",\"childField\":\"child\",\"superField\":\"super\"}"
, it may fail sometimes because the order could be different than the expected order i.e repeatField, childField, superField.Error:
Instead of comparing json strings, we can convert json to Map and then compare the maps. This PR proposes to compare Maps instead of json strings in test4.
You can run the following commands to run test4 using NonDex tool:
Test Environment:
Kindly let me know if this fix is acceptable.
Thank you