27
BDD L’ARTE DI NON FARSI I FATTI PROPRI

Bdd - L'arte di non farsi i fatti propri

Embed Size (px)

Citation preview

Page 1: Bdd - L'arte di non farsi i fatti propri

BDD L’ARTE DI NON FARSI I

FATTI PROPRI

Page 2: Bdd - L'arte di non farsi i fatti propri

Bdd

Ovvero l’arte di non farsi i fatti propri

Page 3: Bdd - L'arte di non farsi i fatti propri

whoami

Software developer @

abuggin

Page 4: Bdd - L'arte di non farsi i fatti propri

TDD - Test Driven DevelopmentWHAT?

Page 5: Bdd - L'arte di non farsi i fatti propri

TDD - Test Driven Development

Page 6: Bdd - L'arte di non farsi i fatti propri

TDD - Test Driven Development

Page 7: Bdd - L'arte di non farsi i fatti propri

TDD - Test Driven DevelopmentWHAT?

Page 8: Bdd - L'arte di non farsi i fatti propri

TDD - Test Driven DevelopmentWHAT?

Page 9: Bdd - L'arte di non farsi i fatti propri

TDD - Test Driven Development - HOWThink -> what to test

-> how to test it

Code test -> Red bar

Code source -> Green bar

Refactor -> Design

-> Green bar

Repeat ad libitum

Page 10: Bdd - L'arte di non farsi i fatti propri

TDD - Test Driven DevelopmentWHO?

Page 11: Bdd - L'arte di non farsi i fatti propri

TDD - Test Driven DevelopmentWHY?

Com’è nato? -> History Class

Perché lo fanno? -> that’s more interesting

(god why?)

Page 12: Bdd - L'arte di non farsi i fatti propri

History Classhttp://wiki.c2.com/?CodeAndFix

Page 13: Bdd - L'arte di non farsi i fatti propri

Tdd - Expected Benefits- significant reductions in defect rates,

- cost of a moderate increase in initial development effort

- these overheads are more than offset by a reduction in

effort in projects' final phases

- veteran practitioners report that TDD leads to improved

design qualities in the code, and more generally a higher

degree of "internal" or technical quality

Page 14: Bdd - L'arte di non farsi i fatti propri

Tdd problems 101Il problema nasce da:

Da dove inizio? -> o meglio: Da dove inizio a testare?

Quanto testo?

Cosa testo?

Page 15: Bdd - L'arte di non farsi i fatti propri

Tdd - Typical Mistakes- forgetting to run tests frequently

- writing too many tests at once

- writing tests that are too large or coarse-grained

- writing overly trivial tests, for instance omitting

assertions

- writing tests for trivial code, for instance accessors

Page 16: Bdd - L'arte di non farsi i fatti propri

Tdd - Team Pitfalls- partial adoption - only a few developers on the team use

TDD

- poor maintenance of the test suite - most commonly

leading to a test suite with a prohibitively long running

time

- abandoned test suite (i.e. seldom or never run) -

sometimes as a result of poor maintenance, sometimes as a

result of team turnover

- Tests can only be read by developers

Page 17: Bdd - L'arte di non farsi i fatti propri

[Dan North cit.]TDD is an effective way of ensuring your code works. However,

if the methods do not comprehensively describe the behaviour

of your system, then they are lulling you into a false sense

of security.

Page 18: Bdd - L'arte di non farsi i fatti propri

Bdd to the rescue 101Dove inizio a testare?

Quanto testare?

Business goal

In una singola frase non

puoi testare piu’ di un

behaviour

Page 19: Bdd - L'arte di non farsi i fatti propri

Bdd to the rescue 101Define a story

Create scenarios for that story

Specify behaviors of your system for those scenarios

Page 20: Bdd - L'arte di non farsi i fatti propri

Bdd to the rescue - collaborationEmphasis on collaboration:

- talk with the stakeholders to understand your assumption

- Using business-readable, executable specifications tests

your assumption even before testing your code works.

- There shouldn’t be any different languages in the same

orgs: ubiquitous language

Page 21: Bdd - L'arte di non farsi i fatti propri

Bdd specs exampleGiven

When

Then

Five Why’s principle

https://en.wikipedia.org/wiki/5_Whys

Page 22: Bdd - L'arte di non farsi i fatti propri

Bdd specs example - Bowling KataGiven

When

Then

scoring for complete game

when no pins are knocked

down

0 is the final score

Page 23: Bdd - L'arte di non farsi i fatti propri

Bdd specs example - Bowling KataGiven

When

Then

scoring for complete game

when no pins are knocked

down

0 is the final score

Page 24: Bdd - L'arte di non farsi i fatti propri

concordionhttp://concordion.org/tutorial/java/markdown/

Page 25: Bdd - L'arte di non farsi i fatti propri

Mob Programming

Page 26: Bdd - L'arte di non farsi i fatti propri

[t/b]dd

Ovvero l’arte di non farsi i fatti propri

Page 27: Bdd - L'arte di non farsi i fatti propri

Den gghiu’