Mikado Method
Setting up test data for your first test takes a lot of time. That’s not going to help us to test our bugs in legacy code! Let’s try the Mikado Method to:
- be able to setup this test data step by step
- spread this work over many days, weeks, and people
Present the Mikado Method
The Mikado Method is a technique to incrementally do large refactorings, alongside feature delivery.
You’ll find resource about the Mikado Method here or on your room walls.
Rapid Response Question
As a group, what are the top 5 most important things about the the Mikado Method?
Live code the beginning of the Mikado Graph here
To help you to get started, here is a demo of how to use the Mikado Method in our particular situation.
Video Screen Shots
Mikado Graph
Screen-shot of the Mikado Graph from the video
Code Snippets
Code of InvoiceTest from the video
@Test
void Mikado_Method_Constraint_Applies_tax_rules_when_computing_total_amount() {
Country usa = new Country("USA", Currency.US_DOLLAR, Language.ENGLISH);
Invoice invoice = new Invoice("Joe", usa);
}
DIY
Now that you have a better idea, grab a whiteboard, a marker, some post-its and start creating your own mikado graph to add a test.
Delete the tests
In real life, you would
- Fix the bugs
- Start the mikado method to setup your test data
So let’s Ignore or Comment-Out the previous tests!
Use Mikado Method to setup data for a test on Invoice
We’ll first focus on testing the Invoice (java | c++ | c# | kotlin | scala) class. It’s simpler and achievable given the time we have.
To solve this section, use the test entitled Mikado_Method_Constraint_Applies_tax_rules_when_computing_total_amount!
Write your test as if you could instantiate your objects, and start to draw your mikado graph.
Make sure your project keeps building all the time. Notice every time you have something useful.
Use Mikado Method to setup data for a test on Report Generator (advanced)
If you have the time, repeat the same exercise with the test on ReportGenerator (java | c++ | c# | kotlin | scala) class. |
Mini-retro
Time for a mini-retro again.
Take a few minutes to discuss the good and the bad of this approach.
Then compare them to what people usually say in the Retrospectives Guide
Continue: