4 ms·
Lolwut? Unit tests are one of the few things that give me confidence in my refactored code. Integration tests are nice, but they don’t give me enough confidenc
by Aeolun 5y ago
Lolwut? Unit tests are one of the few things that give me confidence in my refactored code.
Integration tests are nice, but they don’t give me enough confidence about the specific part of the system I’m altering.
- bluGill 5y agoUntil you realize that your api is wrong. So long as you got your api right up front unit tests make it easy to refactor. As soon as the api needs nontrivial changes you are sunk.
- grayclhn 5y agoCool, but that’s not “refactoring.”
- Aeolun 5y agoTrue, to some extend. But the number of times I need to do that is low compared to the number of times I need to do a much milder refactor.
- JoshuaDavid 5y agoIf your api is wrong, and you have unit tests for that wrong api, and you have time to rewrite it the right way, you can write a set of methods with the correct api which is a shim for the wrong api (you don't care about perf here), write your refactored version, and switch your now-tested shim to the correct api (and then probably keep it as a reference for the new way of doing things). If you find yourself doing this frequently though unit tests might not be ideal for your situation.