3 ms·
I only use unit tests as a temporary critic when developing brand new abstractions from scratch. With complex implementations, it is incredibly easy to forget o
by bob1029 6y ago
I only use unit tests as a temporary critic when developing brand new abstractions from scratch. With complex implementations, it is incredibly easy to forget one out of hundreds of constraints and lose track of important capabilities as you go.
That said, the moment the abstraction is in a clean state and consistently passing all tests and has been integrated well with existing logic, the unit tests are deprecated as far as I am concerned. I wont ever explicitly delete them, but I recognize that the unit tests are potentially just as flawed as what they are testing (the same developer wrote them after all), and coming back into that abstraction after 6+ months elapses means I'd probably just have to rewrite tests from scratch as a mental exercise and in order to restore my own sanity.
I can recall at least one occasion where I wasted 2 days chasing down a failing unit test only to find out the test itself was flawed - in the worst way, random pass/fail based on a race condition between multiple threads that were part of the testing code. I think that's the biggest danger with unit testing. Other developers assuming the tests you wrote are foolproof and sending them on pointless errands.