3 ms·
> whether or not to use random data in unit tests. Don't. That's not a unit test anymore; that's fuzzing. Which is a great thing to do! But it doesn't belong i
by pavel_lishin 7y ago
> whether or not to use random data in unit tests.
Don't. That's not a unit test anymore; that's fuzzing. Which is a great thing to do! But it doesn't belong in unit tests.
Why? The problem isn't a computer problem, it's a psychology problem.
If your tests start intermittently failing, your developers - you - will just start hitting "re-run tests". You'll tell yourself you won't, of course, but then will come that day when you must fix something in production, so you just slap "run again" and promise you'll fix it later. And maybe you will. But over the course of time, people will just blame "flaky fuzzy tests" on failures, and stop following up, because hey - we've never seen this in production! We'll get around to fixing it, later. And then you start ignoring real test failures, or slapping "retry" half a dozen times before realizing your failures are real.
This will rot your engineering organization.