Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

22
Test-Driven Development e Sviluppo Incrementale Andrea Francia TDD Milano @ Mikamai (10 gennaio 2017)

Transcript of Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Page 1: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Test-Driven Development e Sviluppo Incrementale

Andrea Francia TDD Milano @ Mikamai (10 gennaio 2017)

Page 2: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Chi sono?• Andrea Francia

• Programmatore specializzato su Test-Driven Development

• Docente c/p Scuola XP

• Corso su richiesta: “TDD su Codice Esistente” [email protected]

Page 3: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Come ci insegnano TDD?

Page 4: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Kent Beck. 1999. Extreme Programming Explained: Embrace Change

(Senza Test) Legacy Code

(TDD) Clean Code That Works

Page 5: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

http://ronjeffries.com/xprog/what-is-extreme-programming/

Page 6: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Sappiamo già come funziona il TDD?

1.write a test

2.watch it fail

3.make it pass

4.repeat

Page 7: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

The TDD cycle• Add a little tests

• Run all tests and fail.

• Make change.

• Run the tests and succeed.

• Refactor to remove duplication.

Kent Beck from TDD by Example

Page 8: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Quali sono gli ingredienti del TDD?

• Sviluppo Incrementale

• Test First

• Design Incrementale (detto refactor)

Page 9: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

TODO list (1)• We’ll make a to-do list

• 1) to remind us what we need to do,

• 2) to keep us focused,

• 3) and to tell us when we are finished.

Page 10: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

TODO list (2)

• When we start working on an item, we’ll make it bold, like this. When we finish an item, we’ll cross it off, like this. When we think of another test to write, we’ll add it to the list.

Page 11: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

The TODO list is a live document

Page 12: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Example

http://www.eecs.yorku.ca/course_archive/2003-04/W/3311/sectionM/case_studies/money/KentBeck_TDD_byexample.pdf

Page 13: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Dove la scrivo?

Page 14: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Ho un problema da risolvere, da dove parto?

Page 15: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Cosa ci scrivo?

Page 16: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

All’inizio scriviamo tutti i test che sappiamo che

dovremmo fare

Page 17: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Meglio partire dall’happy path.

Page 18: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Durante il lavoro aggiungiamo ogni cosa

che non possiamo fare ora.

Page 19: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

https://it.wikipedia.org/wiki/File:Pair_programming_1.jpg Author: Lisamarie Babik

Page 20: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Esercizio

Page 21: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

Elephant Carpaccio exercise

http://alistair.cockburn.us/Elephant+Carpaccio+exercise

Page 22: Test-Driven Development e Sviluppo Incrementale (TDD-Milano 2017-01-10)

GrazieAndrea Francia@andreafrancia