logoalt Hacker News

whynotmaybetoday at 3:02 PM5 repliesview on HN

Because it should be `today + 1 year + randomInt(1,42) days`.

Always include some randomness in test values.


Replies

zelostoday at 4:26 PM

Generate fuzz tests using random values with a fixed seed, sure, but using random values in tests that run on CI seems like a recipe for hard-to-reproduce flaky builds unless you have really good logging.

CoastalCodertoday at 3:25 PM

> Always include some randomness in test values.

If this isn't a joke, I'd be very interested in the reasoning behind that statement, and whether or not there are some qualifications on when it applies.

show 2 replies
rcxdudetoday at 3:10 PM

Not a good idea for CI tests. It will just make things flaky and gum up your PR/release process. Randomness or any form of nondeterminism should be in a different set of fuzzing tests (if you must use an RNG, a deterministic one is fine for CI).

show 2 replies
devintoday at 3:09 PM

Are you joking? This is the kind of thing that leads to flaky tests. I was always counseled against the use of randomness in my tests, unless we're talking generative testing like quickcheck.

show 2 replies
andaitoday at 3:08 PM

Interesting, haven't heard this before (I don't know much about testing). Is this kind of like fuzzing?

show 1 reply