depgraph-maven-plugin icon indicating copy to clipboard operation
depgraph-maven-plugin copied to clipboard

Fix a flaky test for GraphIntegration

Open Ethan-Chin opened this issue 4 months ago • 0 comments

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:
mvn edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=com.github.ferstl.depgraph.GraphIntegrationTest#graphInJson
  • 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.

Ethan-Chin avatar Oct 06 '24 22:10 Ethan-Chin