How to test legacy code with hardwired dependencies. This talk explains how to deal with legacy code wisely. This presentation should be done with a live code based on the TripService Kata created by Sandro Mancuso.
7. DON’T BE AFRAID BY A DAUNTING SITUATION
SO, HOW TO START?
Many classes
Many lines of code
Many warnings from Code Metrics
Never built with testability in mind
9. CLEAN THE DECK
HOW TO START?
Delete commented out and unused code
Makes the code easier to understand
You don’t want to write unnecessary tests
Tools like Resharper for .NET can help
The compiler is a reliable ally
Remember you have version control for
emergencies (hopefully)
10. DO NOT ATTEMPT A BIG BANG
HOW DO I KNOW THAT I‘M NOT BREAKING ANYTHING?
11. DO NOT ATTEMPT A BIG BANG
HOW DO I KNOW THAT I‘M NOT BREAKING ANYTHING?
Changing all the code to add unit tests
Will break everything!
Start small and work outwards
Velocity will be low initially
Should increase as test coverage increases
Use code coverage as a useful metric
But don’t be enslaved by it
12. HOW DO I KNOW THAT I‘M NOT BREAKING ANYTHING?
MOVE ON CAREFULLY
13. HOW DO I KNOW THAT I‘M NOT BREAKING ANYTHING?
MOVE ON CAREFULLY
Hyperaware Editing
Preserve Signatures
Single-Goal Editing
Lean on Compiler
Pair Programming
15. Bruno BOUCARD @brunoboucard #LearnToCraft
DON’T BE AFRAID BY A DAUNTING
SITUATION CLEAN THE DECK
DO NOT ATTEMPT A BIG BANG MOVE ON CAREFULLY
APPLY BREAKING
DEPENDENCIES TECHINQUES
HOWTOSTARTHOWTONOTBREAKANYTHING?
INSUMMARY