3 ms·
I wonder if this says something about the nature of test code?
by dboreham 4y ago
I wonder if this says something about the nature of test code?
- djbusby 4y agoSure, it's been loads of boilerplate since forever.
- throwawaysleep 4y agoTests often have tons and tons of boilerplate
- jacurtis 4y agoTest are always mostly boilerplate and rarely include anything crafty. 95% of tests are: instantiating a class, running a method, and then asserting that the result. Tests do not or should not be crafty creative code snippets. They are boring functional code blocks by design and most are very similar, only changing out inputs and assertions between tests.
- paledot 4y agoI'd go so far as to say if your test is doing something crafty, you're doing tests wrong. Maybe in a mock or fixture, but that's a write-once sort of affair. I also don't apply DRY (don't repeat yourself) to tests. Tests should be independently readable beginning to end, no context needed. After all, the true value of a unit test is to take a block of code too complicated to easily fit in your mind, and break it down into a series of examples simple enough to fit.