Live-Testing bugs in legacy code with test data builders and the mikado method
"Remember to add tests before you fix any bugs!" That’s very nice in theory, but a lot more tricky in practice.
We know we need to add tests, but it’s more easily said than done. In legacy codebases, just setting up the objects for the test is most often an unjustifiable nightmarish 2 weeks work. Mocks are a common workaround, but mocking legacy codebases usually makes them more difficult to change, not less!
In this live coding presentation, we will combine the mikado method with test data builders to build a baby-step plan to add the first test to a legacy codebase. We'll draw a graph of nested test data builders so that we can instantiate test data, without mocks.
In more details:
Test Data Builders simplify and factorize test data initialization.
The Mikado Method is a technique to split a large refactoring in a graph of baby-steps.
These baby steps remain deployable at any time and don’t block other development.
When we combine these 2 techniques together, we get an incremental plan to create test data builders.
At every step, test data is easier to initialize, the overall testability improves, helping everyone to add more tests.
Driven by usage, critical code parts naturally get testable first.
By making reuse and extend the easiest option, these techniques are viral, and snowball.
Relying on a visual mikado graph, these techniques are collaborative by design.
Back at work, you'll be able to practice this session yourself with the open-source kata. After that, you should be able to inject these contagious testing techniques into your team!
Let’s not waste our lives on loosy work! I help software engineers to reach an effective and sustainable pace through continuous refactoring of their code and organizations.
Currently Technical Agile Coach at Murex