fix flaky tests in ParametersTest#2820
Conversation
|
Thanks @qz0610 for finding this flaky test and submitting a fix. I have one concern with the solution which is that the array returned by For example Perhaps we could reconstruct the returned parameters back into a HashMap and assert equality on that to ensure the key-value pairing remains correct. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2820 +/- ##
============================================
+ Coverage 76.16% 76.47% +0.31%
- Complexity 13170 13934 +764
============================================
Files 1085 1076 -9
Lines 65189 63324 -1865
Branches 7289 7457 +168
============================================
- Hits 49651 48428 -1223
+ Misses 12830 12367 -463
+ Partials 2708 2529 -179 ☔ View full report in Codecov by Sentry. |
|
Thank you @Cole-Greer for pointing out my overlook of the reservation of key-value pairs, and the suggestion of reconstructing a HashMap. I updated the fix by comparing the expected HashMap with the one reconstructed from |
|
I'm curious, wouldn't this same problem affect other tests in that class like |
|
Hi @kenhuuu, thank you for the insight. You are absolutely correct. This same problem also affects shouldGetKeyValues() and shouldGetKeyValuesIgnoringSomeKeys() in ParametersTest. I updated the fix to include fixing these two tests. After the fix, all tests in ParametersTest have no more failures with nondex configuration. |
|
I think it would have been a little nicer if a short helper method was used to create those Maps but it's OK since this is just a test file. VOTE +1. |
|
Thanks for all of the updates to the tests. Normally we ask that a PR such as this would be targeted to the VOTE +1 (merging as a CTR) |
Description
One flaky test shouldAllowNullValues is found using Nondex. This PR now fixes it without introducing new plugins / dependencies. The test was found to be flaky when running the following command:
The
paramsarray contains retrieved keys and value from a HashMap, that may lead to inconsistent test results due to the non-deterministic ordering of elements in a HashMap.Proposed Fix
The expected keys and values are now stored in a new array 'expected'. Sort both 'params' and 'expected'. The comparison between 'params' and 'expected' has consistent results.