This was an excellent read; we spend a fair bit of time wondering what to test and relatively little on why we’re testing. This post changed how I think about testing. https://madeintandem.com/blog/five-factor-testing/
Key points – Sarah describes five reasons for writing automated tests:
- Verify the code is working correctly
- Prevent future regressions
- Document the code’s behaviour
- Provide design guidance
- Support refactoring
All pretty unexceptionable; but the bit that was new to me was, those things aren’t mutually compatible, and there are always tradeoffs – tests that thoroughly document the functionality at a low level can make it much harder to refactor or add new functionality, for example, and the right mix of tests depends on your individual situation – how important to you and your project is each of the five factors?