Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Testing sur Legacy Code
Search
Jean-Laurent de Morlhon
November 20, 2013
Programming
73
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Testing sur Legacy Code
Jean-Laurent de Morlhon
November 20, 2013
More Decks by Jean-Laurent de Morlhon
See All by Jean-Laurent de Morlhon
Retour Sur DockerCon 2016 - Docker Mega Meetup
jeanlaurent
1
140
Retour sur DockerCon 2016
jeanlaurent
2
220
Pourquoi Maurice ne doit surtout pas coder en Go.
jeanlaurent
0
190
Diamond Kata Workshop
jeanlaurent
0
200
Testing sur code legacy
jeanlaurent
0
140
FruitShop
jeanlaurent
3
860
Phantom, Zombie & Karma, overview of the greatest testing tools for modern web app
jeanlaurent
5
780
Live Coding Tester une Application HTML5
jeanlaurent
1
110
Le fantome, le zombie et testacular Karma. Panorama des outils de tests pour application web moderne.
jeanlaurent
1
110
Other Decks in Programming
See All in Programming
Built Our Own Background Agent at LayerX #aidevex_findy
layerx
PRO
8
3.4k
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
2.6k
『コードを書く以外の』エンジニアリング〜課金基盤移行プロジェクト推進のためのTips4選
yuriko1211
0
540
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
550
GitHubCopilotCLIのスラッシュコマンドを自作してみる
htkym
0
110
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
240
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
370
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
560
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
360
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
7
6.9k
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
670
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3.1k
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
910
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Product Roadmaps are Hard
iamctodd
55
12k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.5k
Optimising Largest Contentful Paint
csswizardry
37
3.8k
Raft: Consensus for Rubyists
vanstee
141
7.6k
Crafting Experiences
bethany
1
230
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
260
New Earth Scene 8
popppiees
3
2.4k
We Have a Design System, Now What?
morganepeng
55
8.2k
Transcript
TESTING SUR CODE LEGACY Jean-Laurent de Morlhon
WHO'S WHO ? Nom & rôle dans votre entreprise ?
Expérience professionnelle ? Votre niveau en testing sur du code legacy ?
AGENDA Présentation Craftsmanship Testing & Legacy Gilded Rose Legacy Code
Refactoring WrapUp 4 % 4 % 12 % 24 % 48 % 8 % Présentation Craftsmanship Testing & Legacy Gilded Rose Mayhem Wrap Up
CRAFTSMANSHIP
Process Coding CRAFTSMANSHIP
Attitude
MENTORING & TRAINING
TESTING & LEGACY
None
TAXONOMIE DES TESTS Tests unitaires Tests d'intégrations e2e Tests de
performance Tests de charge Tests exploratoires Tests d'ergonomie Automatisées manuels
TEST UNITAIRE @Test public void should_find_winning_bids_when_there_is_option_bids() { Bid bid =
new Bid(); bid.setStatus(OPTION); ExpiredBids expiredBids = new ExpiredBids(); expiredBids.add(bid); assertThat(expiredBids.isAnyWinning()).isTrue(); } Test très technique Teste une classe en isolation des autres Ultra rapide (< 10ms)
TEST D'INTÉGRATION Test souvent technique Teste le comportement de plusieurs
composants ensemble Rapide à lent ( 500ms ~ 1s) @Test public void i_can_retrieve_auctions_bided_by_an_investor() { Investor investor = investors.add(buildInvestor()); Auction auction = auctions.add(buildAuction()); auctions.addBidToAuction(auction.getId(), buildBid()); assertThat(auctions.fromInvestors(investor.get_id())).isNotEmpty(); }
TEST END 2 END Test souvent fonctionnel Teste toute l'application,
souvent via l'interface Lent (+1s) it 'should find my company account from siren', (done) -> browser = new Browser() browser.visit home, -> browser.clickLink 'Inscrivez-vous', -> browser.choose 'une entreprise' browser.pressButton 'Envoyer', -> browser.fill 'sirenCode', '394149496' browser.clickLink 'Rechercher', -> expect(browser.evaluate('$(\'input[name="e"]\').val()')).to.equal 'SERPODILE' done()
TECHNIQUES
TEST "AFTER" J'écris du code J'écris un test qui couvre
le code que je viens d'écrire du mieux que je peux. Facile à faire Génère des tests d'intégrations Tests souvent compliqués.
TDD Ecrire un test unitaire qui échoue Faire passer le
test simplement Refactor Switch de clavier
TECHNIQUE OUTSIDE-IN Ecrire un test d'acceptance qui échoue Ecrire un
test unitaire qui échoue Faire passer le test simplement Refactor
BDD - TDD WITH STYLE Scenario: substract two numbers Given
I have entered 10 in the calculator And I have entered 7 in the calculator When I press substract Then the result should be 3 on the screen
LEGACY CODE ? Un système en production Manque de maintenance
Manque de tests Customization Locking Pas de source
PYRAMIDE DES TESTS Tests unitaires Tests d'intégrations e2e 1-5% 5-15%
80-90% + - Temps Complexité Fragilité
PYRAMIDE DES TESTS 0-5% 5-15% 80-90% + - Temps Complexité
Fragilité e2e Tests d'intégrations Tests unitaires
INVERSER LA PYRAMIDE e2e Tests d'intégrations Tests unitaires Tests unitaires
Tests d'intégrations e2e Système legacy Système sous contrôle
INVERSER LA PYRAMIDE 4 règles du design simple Attitude Boy
Scout Rule Appropriation collective du code Politique de tests Design émergent
4 RÈGLES DU DESIGN SIMPLE 1. Tous les tests passent
2. Révèle ton intention 3. Evite la duplication 4. Petites classes & petites méthodes
FENETRE CASSEE
PAIR PROGRAMMING
DESIGN EMERGENT
RÈGLE DU BOY SCOUT
TOUT EST LIÉ
CODE
GILDED ROSE https://github.com/xebia-france/gildedrose-kata Exercice de refactoring sur legacy Par binôme
Tentez une technique Vous êtes la pour expérimenter, apprendre Pas pour "gagner" l'exercice. Niveau: moyen 1h30
MAYHEM https://github.com/jeanlaurent/devoxx-legacy-code-labs MAY-HEM: A state of violent disorder or riotous
confusion; havoc 3h Exercice de refactoring sur legacy Par binôme Niveau: difficile
UN PEU DE LECTURE
CONTACT
[email protected]
@morlhon http://code-story.net http://morlhon.net/blog