The test instability arises from an incorrect assumption about the sequential arrangement of keys in JSON files. Two JSON files may be equivalent even if their text formats differ because the key order in JSON can vary without affecting the data structure.
The original test function graphInJson inaccurately compared the source JSON to the expected JSON by matching the text directly and asserting file content equivalence. This approach is overly stringent for JSON files, where key order can be non-deterministic.
To address this issue, a JSON comparison function has been implemented using the Jackson library, which properly compares JSON objects based on their content and structure, disregarding the order of keys.
Fixed a flaky test in
com.github.ferstl.depgraph.GraphIntegrationTest.graphInJson
.To identify the flaky test, execute the following nondex command after compiling the module:
The test instability arises from an incorrect assumption about the sequential arrangement of keys in JSON files. Two JSON files may be equivalent even if their text formats differ because the key order in JSON can vary without affecting the data structure.
The original test function
graphInJson
inaccurately compared the source JSON to the expected JSON by matching the text directly and asserting file content equivalence. This approach is overly stringent for JSON files, where key order can be non-deterministic.To address this issue, a JSON comparison function has been implemented using the
Jackson
library, which properly compares JSON objects based on their content and structure, disregarding the order of keys.