News for hackers. Stuff that matters.
Re:Is TDD Dead? (2014) by hinkley on Wednesday August 26, 2020 @12:02PM (#24283730)
I’ve watched this play out a few times with different teams and different code bases (eg, one team two projects).

Part of the reason existing tests lock in behavior and prevent rework/new features is that the tests are too complicated. Complicated tests were expensive to write. Expense leads to sunk cost fallacy.

I’ve watched a bunch of people pair up for a day and a half trying to rescue a bunch of big ugly tests that they could have rewritten solo and in hours if they understood them, learn nothing, and do the same thing a month later. The same people had no problem deleting simple tests and replacing them with new ones when the requirements changed.

Conclusions:

- the long term consequences of ignoring the advice of writing tests with one action and one assertion are outsized and underreported.

- change your code so the don’t need elaborate mocks

- choose a test framework that supports setup methods

- choose a framework that supports custom/third party assertions, sometimes called matchers. You won’t use this often, but when you do, you really do.

There are no comments on this comment yet.