Hacker News new | ask | show | jobs
by hashkb 1227 days ago
You can mock the RNG. You don’t need to test/prove it’s random, you need to test your code which is not random.
1 comments

unit tests are notoriously bad about testing n>2. I just ran into a problem with sorting recently that was caused by buggy comparators, but it didn't bubble up to the tests until the runtime switched to a different sort implementation. Most of the tests were doing n=2 so it was not visible under the old runtime version but was under the new one. This has been broken in production for months if not years. If the test had used n=5 I'm pretty sure the old tests would fail as well.