3 ms·
We developers write code. That code can be application/library code or test code. The overall goal is to deliver the application/library. As with most things i
by magicalhippo 3y ago
We developers write code. That code can be application/library code or test code. The overall goal is to deliver the application/library.
As with most things in life, I find the best approach is seldom at an extreme. The time spent on writing tests should only be spent if those tests help you achieve the overall goal better than spending that time writing application/library code. And vice versa.
With that in mind I feel I get the most bang for my buck primarily writing higher-level tests like integration tests. These will test that the core functionality works, and cover larger parts of the code-base.
Like Lego, the pieces might be perfectly in spec and the error might be in how they're put together. Thus unit testing will only get you so far, and I mostly reserve unit testing for smaller pieces of library-style code, especially if there's tricky edge cases involved.
- whstl 3y agoI have come to the same conclusions. I would also add that I prefer higher-level integration tests because I want the tested code to be malleable in case I need to refactor in the future. To me unit tests take away some of this malleability. I write unit tests for the same cases you do, however I also tend to write mostly unit tests for regression testing, which sorta breaks my own rule.