Member-only story
Sandwich testing — a way to overcome testing fatigue?
Test-driven development (TDD) has become the gold standard in software development and has proven its worth in millions of projects. In addition to TDD, the SOLID principles of software development are also a key component in creating clean, readable, and refactor-friendly code.
A minor side effect of these two is that you will have to create thousands of unit tests to ensure good code coverage of your solution. As a consequence, you may, like me, have experienced testing fatigue as the solution grows to several hundred classes spanning ten-thousands lines of code.
Testing fatigue and how to overcome it
For me, a typical development session may run as follows.
- I start with TDD as a bottom-up testing approach.
- For a while, I write unit tests to test the lower-level code extensively.
- The codebase matures and I start to write integration code that calls other code, sometimes up to 10 layers deep in the call stack. This is a consequence of the “Single-responsibility” principle of SOLID.
- Writing many unit tests becomes a larger and larger task. Mocks for mocking out lower-level code become tedious. At this point, following TDD+SOLID to the point comes with a rather large overhead…