3 ms·
Dogmatic unit testing is overrated. For backend testing, I've had amazing success following a few simple principles: 1. Abstract and mock code you don't contro
by calderwoodra 5y ago
Dogmatic unit testing is overrated.
For backend testing, I've had amazing success following a few simple principles:
1. Abstract and mock code you don't control that require network calls.
2. Use frameworks that support database abstraction out of the box
3. Test end to end functionality. Every test should basically be getting your DB into a specific state, then hitting an API endpoint and validating the output and/or state change.
It's not that hard, you can get decent and worthwhile code coverage for not much work, and even if you only write a few tests with low coverage, you can easily add regression tests later if you notice a bug.