tdd outside in - coding dojo lyon

12
TDD Outside-In CODING DOJO DU 24 NOVEMBRE 2015

Upload: florentpellet

Post on 15-Jan-2017

555 views

Category:

Software


2 download

TRANSCRIPT

Page 1: TDD outside in - Coding Dojo Lyon

TDD Outside-InCODING DOJO DU 24 NOVEMBRE 2015

Page 2: TDD outside in - Coding Dojo Lyon

Sponsors

Page 3: TDD outside in - Coding Dojo Lyon

Fusion du

Coding Dojo et du

Software Craftsmanship

http://www.meetup.com/fr/Software-Craftsmanship-Lyon/

Page 4: TDD outside in - Coding Dojo Lyon

Evènements à venir

01/12: CARA Lyon“SAFe vu par des "clients" certifiés Scaled Agile Academy”

07/12: Software Craftsmanship Lyon“Event Storming sur un vrai projet”

http://www.lyontechhub.org/

Page 5: TDD outside in - Coding Dojo Lyon

TDD Classique« Chicago school »

• Le TDD enseigné par Kent Beck, Uncle Bob…

• Le TDD généralement mis en œuvre dans les kata

• Concepts associés :• Baby steps• Design émergent

(Refactoring)• Utilise peu de Mock

TDD

RED

GREENREFACTOR

Page 6: TDD outside in - Coding Dojo Lyon

A

D

B C

class ClassAShould { do_something()…

do_something_else()…

do_this_other_thing()…

do…do…do…

}

Page 7: TDD outside in - Coding Dojo Lyon

TDD Outside-in« London school »

• Réflexion sur les responsabilités en amonts

• Approche « Mockist »• Le design se fait dans le

« Red »• Part toujours de

l’exterieur vers l’interieur

TDD(Outside-in)

RED

GREENREFACTOR

Page 8: TDD outside in - Coding Dojo Lyon

A

C

B AD

DB

UT

A

B

BAC

IMDB

C’

B’

UT

C’UT

IT

AT

Crédit : Sandro MANCUSO@sandromancuso

Page 9: TDD outside in - Coding Dojo Lyon

AcceptanceTest

TDD

Ecrire un T.Uen échec

Le faire passer

Refactoriser

Considérer un testen échec

N itérations

Page 10: TDD outside in - Coding Dojo Lyon

Bank Kata

Application bancaire simple : Déposer sur un compte Retirer d’un compte Imprimer un relevé de banque dans la console

Critère d’acceptation : Le relevé doit avoir le format suivant :

DATE | AMOUNT | BALANCE

10/04/2014 | 500.00 | 1400.00

02/04/2014 | -100.00 | 900.00

01/04/2014 | 1000.00 | 1000.00

Commencer par un test d’acceptation

Page 11: TDD outside in - Coding Dojo Lyon

Account Service

public class AccountService {

public void deposit(int amount);

public void withdraw(int amount);

public void printStatement();

}

Page 12: TDD outside in - Coding Dojo Lyon

 Proposed acceptance test starting point;

@RunWith(MockitoJUntiRunner.class)public class PrintStatementFeature {

@Mock Console console;

@Test public voidprint_statement_containing_transactions_in_reverse_chronological_order() {

AccountService accountService = new AccountService();

accountService.deposit(1000); accountService.withdraw(100); accountService.deposit(500);

accountService.printStatement();

InOrder inOrder = inOrder(console);inOrder.verify(console).printLine("DATE | AMOUNT | BALANCE");inOrder.verify(console).printLine("10/04/2014 | 500.00 | 1400.00");inOrder.verify(console).printLine("02/04/2014 | -100.00 | 900.00");inOrder.verify(console).printLine("01/04/2014 | 1000.00 | 1000.00");

}}