Comment on Ask HN: How much emphasis to put on unit testing and when?Comments−hahahahhaah7moIt is a matter of horses for courses. Be driven by what the tests cost and what they accomplish.Costs may be:* Developer time to make and maintain.* CI time means slower CI and higher costs there.* Ossification of source code (especially unit tests, less so integration). Meaning harder to refactor as you also need to rewrite tests.Benefits:* Finds bugs* Can be a handy local dev loop and local debugging loop* Documents code and proves that documentation is correct* Helps with AI assistance* Integration tests should make refactoring easier or more confident.I would err on the side of good coverage (80% excl stupid stuff) unless I have in hand a specific reasin not to.
Comments
It is a matter of horses for courses. Be driven by what the tests cost and what they accomplish.
Costs may be:
* Developer time to make and maintain.
* CI time means slower CI and higher costs there.
* Ossification of source code (especially unit tests, less so integration). Meaning harder to refactor as you also need to rewrite tests.
Benefits:
* Finds bugs
* Can be a handy local dev loop and local debugging loop
* Documents code and proves that documentation is correct
* Helps with AI assistance
* Integration tests should make refactoring easier or more confident.
I would err on the side of good coverage (80% excl stupid stuff) unless I have in hand a specific reasin not to.