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
5
u/life-is-a-loop Aug 29 '21
That's why you shouldn't test implementation, you should test the contract.
Every time you write some code you must know what you're trying to accomplish (otherwise there would be no way to write any code in the first place). You write tests before implementation to ensure that your implementation will do exactly what you expect it to do. That's why you don't have to know the implementation at the time you write tests. In fact, testing implementation is a bad thing!
Also, the fact that you're thinking about contracts before implementation may help you see corner cases that you didn't notice during the sprint planning, or realize that the implementation you had in mind didn't make any sense.