BDD L’ARTE DI NON FARSI I
FATTI PROPRI
Bdd
Ovvero l’arte di non farsi i fatti propri
whoami
Software developer @
abuggin
TDD - Test Driven DevelopmentWHAT?
TDD - Test Driven Development
TDD - Test Driven Development
TDD - Test Driven DevelopmentWHAT?
TDD - Test Driven DevelopmentWHAT?
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
TDD - Test Driven DevelopmentWHO?
TDD - Test Driven DevelopmentWHY?
Com’è nato? -> History Class
Perché lo fanno? -> that’s more interesting
(god why?)
History Classhttp://wiki.c2.com/?CodeAndFix
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
Tdd problems 101Il problema nasce da:
Da dove inizio? -> o meglio: Da dove inizio a testare?
Quanto testo?
Cosa testo?
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
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
[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.
Bdd to the rescue 101Dove inizio a testare?
Quanto testare?
Business goal
In una singola frase non
puoi testare piu’ di un
behaviour
Bdd to the rescue 101Define a story
Create scenarios for that story
Specify behaviors of your system for those scenarios
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
Bdd specs exampleGiven
When
Then
Five Why’s principle
https://en.wikipedia.org/wiki/5_Whys
Bdd specs example - Bowling KataGiven
When
Then
scoring for complete game
when no pins are knocked
down
0 is the final score
Bdd specs example - Bowling KataGiven
When
Then
scoring for complete game
when no pins are knocked
down
0 is the final score
concordionhttp://concordion.org/tutorial/java/markdown/
Mob Programming
[t/b]dd
Ovvero l’arte di non farsi i fatti propri
Den gghiu’