fix: fix flaky test io.dropwizard.health.HealthCheckConfigValidatorTest#startValidationsShouldFailIfAHealthCheckConfiguredButNotRegistered#1
Conversation
|
Using the contains() method repeatedly becomes inefficient as the number of values to check grows. Can you check on the alternative data structures, apart from 'Set', that you can suggest to preserve the order of elements ? |
|
Using the contains() method for every element of the list does not seem scaleable. Consider using another data structure that maintains order. It would be nice if you could add the nondex command used to reproduce the issue. |
231a752 to
0899fac
Compare
|
Hey @Sujishark and @ThugJudy , I don't think it is right to force the order of the values in the string, because the ordering just doesn't matter. |
|
Maybe you also want to assert that the message length. The test should fail if the message contains 2,3,4. It's your call to spend more time addressing the comments or not, but we approve you to proceed to open a real PR. Once you open a real PR, please mark this tentative PR as |
…sShouldFailIfAHealthCheckConfiguredButNotRegistered
c2be776 to
cb15b9a
Compare
Problem:
The HealthCheckConfigValidator#startValidationsShouldFailIfAHealthCheckConfiguredButNotRegistered test is flaky due to the use of the non-deterministic Set<> instance used in the class HealthCheckConfigValidator.
HealthCheckConfigValidator is intended to throw an exception with an error message containing specific words. Due to the use of a Set to generate the error message, this error message is not deterministic because the ordering, in which the elements are returned from the Set, is not deterministic. This results in a flaky test.
The flaky test was found by using the NonDex tool.
Solution:
Instead of checking if the error message contains an array with a specific ordering of the expected strings, check if the error message contains either the one or the other ordering (random ordering as intended by the use of Sets).
Result:
The test is deterministic and not flaky. This improves the quality of the test and reduces the time to search for the bug during future development.
Reproduce: