I've always been and advocate for intentionally ignoring the DRY (Don't Repeat Yourself) rule when writing tests if it makes the tests easier to understand. I've even (repeatably) said that some duplication might actually be a good thing when writing tests.
And then this article on WET (Write Explicit Tests) bubbles up and shows how WET pretty much drives you in the same direction as DRY with some minor but yet significant differences. The key point however is that WET focuses on writing tests that explain intent of each test as clearly as possible while DRY focuses on reducing code duplication. Yet WET also reduces code duplication!
I think this is a brilliant way of helping developers think about their tests "the right way" similar to how BDD is a great way to explain TDD. That is; WET can be seen as DRY implemented properly on tests.
Post a Comment