Fixed flaky test shouldGetClsAsRootEntity in SubjectClosureResolver_TestCase.java#52
Merged
alexsilaghi merged 1 commit intoFeb 21, 2025
Conversation
…estCase by make it deterministic and free from order
alexsilaghi
approved these changes
Dec 10, 2024
Contributor
Author
|
Thanks for reviewing and approving the changes @alexsilaghi. If the changes look good, can we go ahead and merge them as well? Or are there some pending action items from my side? |
Contributor
Author
|
Hi @alexsilaghi following up on this. Since the changes look good, can we go ahead and merge the PR? |
Contributor
Author
|
++ @tudorache for review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 :
shouldGetClsAsRootEntityin 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
shouldGetClsAsRootEntityuses 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.