4 ms·
Perhaps I'm just an outlier, but I think every time I've gone in to write tests for my code (usually post-testing rather than red/green testing), it's rather qu
by andrewstuart2 10y ago
Perhaps I'm just an outlier, but I think every time I've gone in to write tests for my code (usually post-testing rather than red/green testing), it's rather quickly invalidated some assumptions I made when writing the tests.
"Oh yeah, that's going to need to be thread safe."
"Oh yeah, that might be nil. Rather frequently."
In my experience, testing has been much more beneficial as an exercise of my mental model of the code and its interaction than for refactoring. But to that end, I can think of quite a few times that I've been very grateful for a unit test suite while I did a large refactoring.
- Klathmon 10y agoI've had a very similar experience. It's worth it's weight in gold when you can flesh out edge cases and logic issues before going all-in on an architecture, and being able to refactor without fear is a great bonus, but it's not always applicable. Unless the majority of the tests are "external" (i.e. testing an API by calling it's endpoints and testing the return), a major refactor is going to require updated tests, and it's all too common that I see people take the "easy" way out and fix the tests to conform to the way it's working after the refactor rather than the way it should work.
- bluesign 10y agoI agree, tread safety and race conditions I got hit a lot, other than that test coverage provided a lot I guess
- Sean1708 10y ago> tread safety and race conditions I feel like this comment wouldn't be out of place in an F1 thread.
- hoorayimhelping 10y ago>Perhaps I'm just an outlier If you are, then I am as well, because this is where a huge part of the value of tests come from - validating assumptions early and quickly and cheaply.