Fixed flaky test shouldGetClsAsRootEntity in SubjectClosureResolver_TestCase.java #52
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.
What changes were proposed in this pull request?
Changing the assertion from contains() to hasItems() in the testcase :
shouldGetClsAsRootEntity
in classSubjectClosureResolver_TestCase
.Why are the changes needed?
Multiple flaky tests were detected in the above testcase while trying to run the tests using the nondex tool. NonDex is a tool for detecting and debugging wrong assumptions on under-determined Java APIs.
Steps to reproduce flakiness using nondex -
ERROR logs:
Reason for Failure
The method
shouldGetClsAsRootEntity
uses toSet() method which has no guarantee of order.The
contains()
method also checks the order of the entities which are being compared. It checks for the order of the two objects cls and valueEntity as well. This can lead to failure of test case when valueEntity comes after cls. Hence the proposed change is to use method hasItems() which checks if the entities are present in the set or not, irrespective of the order.Please let me know if you have any questions or would like to discuss this further for any clarificaitions.