Tous les deux : Bonjour à toutes et à tous. On va commencer par se présenter très rapidement: Bruno : Je suis coach agile, dont la mission est de transformer des équipes de développement en excellents craftsmen. Avec Jean-Laurent de Morhon nous sommes associés dans le cadre de formations orientées software craftsmanship, notre site s’appelle Learn to Craft. Thomas : je suis architecte technique pour une grande banque d’investissement, mais aussi développeur - en open source notamment- avec la librairie .NET NFluent, qui permet de faciliter l’écriture d’assertions lisibles et « aidantes » dans vos tests. Je pratique le TDD –presque exclusivement depuis 2005, époque où j’ai aussi découvert XP (grâce à ce Monsieur, là à côté ;-)
THE PROBLEM
NEED TO BE REFACTOREDNOT DESIGNED TO BE
TESTABLE
WHY?
NOT DESIGNED TO BE TESTABLE
Hardwired dependencies
Database
Network connection
Third service
Real time
Random
Singletons
Statics
FACT - LEGACY CODE IS NOT DESIGNED TO BE TESTABLE
FACT - LEGACY CODE IS NOT DESIGNED TO BE TESTABLE
DON’T BE AFRAID BY A DAUNTING SITUATION
SO, HOW TO START?
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
CLEAN THE DECK
HOW TO START?
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)
DO NOT ATTEMPT A BIG BANG
HOW DO I KNOW THAT I‘M NOT BREAKING ANYTHING?
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
HOW DO I KNOW THAT I‘M NOT BREAKING ANYTHING?
MOVE ON CAREFULLY
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
LIVE CODE
TRIPSERVICESHARED YOUR TRIP
AND HAVE FUNSource : Sandro Mancuso
https://www.youtube.com/watch?v=_NnElPO5BU0
Bruno BOUCARD @brunoboucard #LearnToCraft
DON’T BE AFRAID BY A DAUNTING SITUATION CLEAN THE DECK