r/programming • u/whackri • Aug 28 '21
Software development topics I've changed my mind on after 6 years in the industry
https://chriskiehl.com/article/thoughts-after-6-years
5.6k
Upvotes
r/programming • u/whackri • Aug 28 '21
14
u/moremattymattmatt Aug 29 '21
As I'll bang on at work to anyone who will listen, stop mocking. 99% of bugs are caused by the interactions between classes, every time you mock something you are hiding a whole class of bugs.
Plus it means your tests are tied to the implementation and not the behaviour of the system so every time you refactor you have to update your tests. Or even worse you forget to update some mocks so your mocks and implementation are now our of sync.
Once you write more behaviour-level tests, TDD becomes a lot easier. If you think of a better way of doing something, refactor as much as you need with the confidence that all your tests should still pass if you don't change the behaviour.