Testing is Part of the Production System
originally published December 13th, 2022I suspect that the typical approach to testing produces more brittle production systems.
I intuit that we’re far less likely to “scout" what we perceive to be ‘test code’ than ‘production code’.
I see a lot of idea duplication in tests, the kind that we would avoid in production. Are we less likely to design structure for our tests than for the rest of the code? For example, I’ve seen testing capabilities implemented as TestCase base classes or traits. These are both approaches that we eagerly avoid in ‘production code’.
I wonder if the idea of ‘production code’ is a useful model. What we end up deploying to production are systems, and tests are one of the most important ways in which we interact with these systems.
We put effort into making our code as comprehensible as possible. I don’t perceive the same diligence of design in test suites. I perceive the consequences are:
- slower test development - reimplementation of fixtures, assertions, etc
- less maintainable tests - redundancy in code implementation makes refactoring difficult.. when refactoring we might have to 100 test-oriented classes that implement redundant behavior
- less comprehensible tests - those redundancies accumulate into messy code that obscures the intended test
In my work, I’m going to continue asking, “are we scouting our test code with the same diligence as the rest of the system?".
Articles
- Delivering Working Software is not Enough
- Do Androids Dream of Microsoft Excel?
- Practical Techniques to Reduce the Harm of Active Record
- Aggregates for Those Familiar with ActiveRecord
- Simplifying Test Development
- Active Record: How We Got Persistence Perfectly Wrong
- Testing is Part of the Production System
- Card-based Simulation Engine
- Test Code is Application Code
- Testing at Boundaries with Test Doubles and Fixtures
- Adding Real Capabilities to Systems Through Naming
- Some Game Projects
- Avoiding Unified Data Models Talk
- More Relaxed Typing with Dvorak
- Event Sourcery
- What is Active Record
- What is Domain Modeling
- Designing A Model Architecture Talk
- A Talk About Naming Things Talk
- Dev Discussions Podcast
- What is a Repository
- Command Bus