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

Post on 13-Apr-2017

92 views 0 download

Transcript of 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)

Chi sono?• Andrea Francia

• Programmatore specializzato su Test-Driven Development

• Docente c/p Scuola XP

• Corso su richiesta: “TDD su Codice Esistente” tdd@andreafrancia.it

Come ci insegnano TDD?

Kent Beck. 1999. Extreme Programming Explained: Embrace Change

(Senza Test) Legacy Code

(TDD) Clean Code That Works

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

Sappiamo già come funziona il TDD?

1.write a test

2.watch it fail

3.make it pass

4.repeat

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

Quali sono gli ingredienti del TDD?

• Sviluppo Incrementale

• Test First

• Design Incrementale (detto refactor)

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.

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.

The TODO list is a live document

Example

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

Dove la scrivo?

Ho un problema da risolvere, da dove parto?

Cosa ci scrivo?

All’inizio scriviamo tutti i test che sappiamo che

dovremmo fare

Meglio partire dall’happy path.

Durante il lavoro aggiungiamo ogni cosa

che non possiamo fare ora.

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

Esercizio

Elephant Carpaccio exercise

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

GrazieAndrea Francia@andreafrancia