Skip to content

Conversation

Ethan-Chin
Copy link

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 Ethan-Chin changed the title a flaky test fixed Fix a flaky test Oct 6, 2024
@Ethan-Chin Ethan-Chin changed the title Fix a flaky test Fix a flaky test for GraphIntegration Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant