-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(flaky): fix paramter type assert in testBothAnnotatedConstructor test case #5751
test(flaky): fix paramter type assert in testBothAnnotatedConstructor test case #5751
Conversation
050166b
to
9832ee1
Compare
@varsha-cl This looks correct. While we are not seeing this issue, I assume it can occur. This is the same as in the other CachedConstructorAnalyzerTest test (yes, we duplicate the test in the incubator module because of its immaturity for the time being) which should be updated the same way. The copyright year needs to be updated to 2024 before this PR's tests pass. |
… in inject module
Thank you the feedback. I have updated the year and replicated the changes in other test file as well |
Description
The
testBothAnnotatedConstructor
test inCachedConstructorAnalyzerTest
fails randomly because constructor selection is non-deterministic when multiple constructors have the same number of parameters. Specifically,BothAnnotatedConstructor
has two single-parameter constructors: one accepting a String and the other an Integer. SincegetDeclaredConstructors
does not guarantee order, the test may select either constructor, leading to intermittent failures.Fix
Adjust the test to validate that the parameter type of the returned constructor is either
String
orInteger
, accommodating both possible outcomes.How Has This Been Tested
Identified this test to be flaky using NonDex tool (which explores different behaviors of under-determined APIs and reports test failures). Here are the commands to run this test case with NonDex tool
Here is the screenshot of the output generated by the NonDex tool
In the above case, we can see that the test case fails intermittently, in the first instance it passed successfully, however in the second instance it failed with error
CachedConstructorAnalyzerTest.testBothAnnotatedConstructor:113 expected: <java.lang.Integer> but was: <java.lang.String>