SlideShare uma empresa Scribd logo
1 de 50
Baixar para ler offline
hello BDD
É,mn eőd
n it laó
Emno,hg métngseűaBD
lodm oy ir ayzr
D
Íyajlnéő i mgsehtkat
g
eelvk s eimrei z
Fraóöy:skrseőds:
ogtknv iee laá ]
Aenie ehnzt a eőds
mnybn lagot z laá
É ahlgtkmgri a ehnztaa
s
alaó eétk z lagotkt
Mj hsnstá atamnenp mnáubn
ad azoíjk z
idnai ukjka
Akreátlbloabklsnk
ko zla odgba eze
É ööübnmgíjka eődt12sre
s rmke ehvá z laó - ör
Fraóöy:skree eőds:
ogtknv ietln laá [
Aenie ehnzt a eőds
mnybn lagot z laá
É ahlgtkuamka eautk
s
alaó nlubn llda
Mj a eődsvgnflbenk
ad z laá éé eérde
Akrmgoájka eődttjsa
ko edblá z laó oásl
D a bzo,hg nmhvá mg12sre
e z its oy e íjk e - ör
hello BDD

TDD, BDD és sok egyéb xBR
SZÁSZ ZOLTÁN
zoltan at szasz.me
@szaszz
/in/zoltanszasz
BEMUTATKOZÁS
10+ éve dev bizniszben
Önjelölt Clean Coder
Dev & Ops, többnyire Dev
Agile / Scrum / Kanban / XP
kedvelő
TDD & automata teszt hívő
Symfony2 fan
PHP Meetup alapító & szervező
2 gyermek büszke apukája
BUSINESS
DRIVEN DEVELOPMENT

VS
BEHAVIOR
DRIVEN DEVELOPMENT
BUSINESS
DRIVEN DEVELOPMENT

=
BEHAVIOR
DRIVEN DEVELOPMENT
TÖRTÉNET
FELTALÁLÓK

Dan North
Chris Matts
Liz Keogh

@tastapod
@papachrismatts
@lunivore
FELTALÁLTÁK
Behavior Driven Development

MEGCSINÁLTÁK
RBehave » RSpec
JBehave
TESZTELÉS

~ISMÉTLÉS A TUDÁS ATYJA~
MIÉRT TESZTELJÜNK?
helyesség
teljesség
robusztusság
regressziók
kizárása
hibák
megelőzése
stb.
MI TÖRTÉNIK, HA

NEM

TESZTELÜNK?
MIÉRT
AUTOMATA TESZTELJÜNK?
úgyis tesztelsz
miért csinálnád
kézzel?
teszt is lehet
komplex
hamar megtérül
stb, stb.
XP TESZT ALAPOK
minden kód unit tesztelt
minden kód „átmegy” a unit teszteken
a tesztek felfedik a hibákat
a tesztek gyorsak, és gyakran futnak
+ a tesztek determinisztikusak és
koherensek
a cél továbbra is pontosan ez
TDD a legegyszerűbb tesztet, és
1. Írd meg
lásd, hogy úgy fail-el, ahogy vártad
2. Teljesítsd a tesztet a
legegyszerűbb kóddal
3. Refaktorálj!
Ismételd, a fenti 3 lépést, míg készen
nem vagy
CLEAN CODE
SOLID
SRP Egy osztály egy dologért felel
OCP Az osztály kiterjeszthető, de nem módosítható
LSP Egy osztály helyett, bármely gyereke használható
ISP Ne függj olyantól, amit nem használsz. A logika kis
interface-eknek feleljen meg.
DIP A működés (logikai szinten) nem a konkréttól,
csupán az absztrakttól függ (decoupling)
„TOVÁBB IS VAN! MONDJAM MÉG?”
YAGNI Mindig csak a szükséges dolgokat
implementáld
DRY Mindent csak egyszer írj meg
KISS Tartsd egyszerűen
FIRST Tesztek

AJÁNLÓ
Magyar Attila – Clean Code slide video
Orcsik Antal – Objektum orientált mérések a
gyakorlatban slide video
Ördög Rafael – Test driven mockery slide video
SZUPER-ZÖLD!
AVAGY A 
„BETÖRT ABLAK”-ELV

is!

Óvakodj a „flaky” teszttől,
meg a „skipped” teszttől
és persze az „incomplete” teszttől
BDD
ALAPOK
SPECIFIKÁCIÓ
FORMÁLIS SPECIFIKÁCIÓ
üzleti szemléletben már a 60-as
évektől
több paradigma
több leíró nyelv
kötöttek
nem rugalmasak
INFORMÁLIS SPECIFIKÁCIÓ
szeretnék egy
olyat...
legyen... kék!
nem jó kék!
nem is!... inkább
piros!
XP SPECIFIKÁCIÓ
USER STORY
Flazáó krss
ehsnlk eeée

#il
tte

Mn rnse amnstáo
it edzr diizrtr
Seenkaflazáó kz krsi
zrté
ehsnlk öt een
Aét hg mgéhse a aaakt
zr, oy enzesm z dtia

#oe
rl
#eur
fate
#eei
bnft

ELFOGADÁSI KRITÉRIUMOK
•flazáó krseőknvé emi cmaajn
ehsnlk eehte é s -al í lpá
•lsanzte ltmanvt emi cmt tlfnzmt
it éebn áo
eé, -al íé, eeosáá
•lsanzte anvektitaarsltsnztjlnkmg
it éebn
ér atnv
ézee ée eei e
•rsltsnzte ltmmne mnetaaá cootsta
ézee éebn áo idn ett dtt sproív
BDD SPECIFIKÁCIÓ
Ami bevált azon miért változtatnánk?

USER STORY
Faue AcutHle wtdascs
etr: con odr ihrw ah

#il
tte

A a AcutHle
s n con odr
Iwn t wtda cs fo a AM
at o ihrw ah rm n T
S ta Icngtmnywe tebn i coe
o ht
a e oe hn h ak s lsd

#oe
rl
#etr
faue
#eei
bnft
AKKOR MI AZ ÚJ?
Scenariók, mint automatán tesztelhető elfogadási
kritériumok
Seai:Acuthssfiin fns
cnro con a ufcet ud
Gvnteacutblnei $0
ie h con aac s 10
Adtecr i vld
n h ad s ai
Adtemciecnan eog mny
n h ahn otis nuh oe
We teAcutHle rqet $0
hn h con odr euss 2
Te teAMsol dses $0
hn h T hud ipne 2
Adteacutblnesol b $0
n h con aac hud e 8
Adtecr sol b rtre
n h ad hud e eund
Seai:Acuthsisfiin fns
cnro con a nufcet ud
Gvnteacutblnei $0
ie h con aac s 1
Adtecr i vld
n h ad s ai
Adtemciecnan eog mny
n h ahn otis nuh oe
We teAcutHle rqet $0
hn h con odr euss 2
Te teAMsol ntdses aymny
hn h T hud o ipne n oe
AdteAMsol syteeaeisfiin fns
n h T hud a hr r nufcet ud
Adteacutblnesol b $0
n h con aac hud e 1
Adtecr sol b rtre
n h ad hud e eund

#il
tte
#otx
cnet
#otx
cnet
#otx
cnet
#vn
eet
#ucm
otoe
#ucm
otoe
#ucm
otoe
EZ MÁR AUTOMATA TESZT?
NEM! ✱

✱

De jó úton járunk :)
DSL
GHERKIN - A NYELV
pontosabban DSL (domain specific language)
leírja a viselkedést, az implementáció ismerete nélkül
„nyakkendősök” is megértik: ügyfél, Product Owner,
Project Manager, Business Analyst, Marketing
fejlesztők is megértik
kötött szintaxissal, de
természetes nyelven írható (~40 nyelv)
.feature fileok (user story + scenariók)
natívan: Ruby, Java, Js, .Net
sok BDD eszköz alap DSL-je (pl: Behat, Behave)
USER STORY
FEATURE | BUSINESS NEED | ABILITY
Faue Ccme etn
etr: uubr aig
A ahnr mn
s
ugy a
Iwn t etsm ccme
at o a oe uubr
S ta Iwntb hnr
o ht
o' e ugy

TESZT ESET
SCENARIO (FORGATÓKÖNYV)
Seai:Et5oto 1
cnro a
u f 2
Gvnteeae1 ccmes
ie hr r 2 uubr
We Iet5ccmes
hn
a
uubr
Te Isol hv 7ccmes
hn
hud ae
uubr
LÉPÉSEK
GIVEN (AMENNYIBEN|ADOTT)
Gvnteeae1 ccmes
ie hr r 2 uubr
Ad6ptt
n
oao
#öboo agmnuo
tbsrs ruetmk
GvnTeevgtbe aeo tetbe
ie hs eeals r n h al:
|vgtbe|aon |
eeal
mut
|ccme |1
uubr
2
|
|ptt
oao
|6
|

WHEN (MAJD|HA|AMIKOR)
We Iet5ccmes
hn
a
uubr
Ad2ptte
n
oaos
LÉPÉSEK
THEN (AKKOR)
Te Isol hv 7ccmes
hn
hud ae
uubr
Ad4ptte
n
oaos

AND (ÉS), BUT (DE)
Te iseccmes
hn
e uubr
Adptte
n oaos
Btid ntseoin
u
o o e no
TESZT VÁZLAT
SCENARIO (OUTLINE | TEMPLATE)
Seai Otie Etn
cnro uln: aig
Gvnteeae<tr>ccmes
ie hr r sat uubr
We Iet<a>ccmes
hn
a et uubr
Te Isol hv <et ccmes
hn
hud ae lf> uubr
Eape:
xmls
|sat|et|lf |
tr
a
et
| 1
2 | 5 | 7 |
| 2
0 | 5 | 1 |
5
ALAPVETÉS
BACKGROUND (HÁTTÉR)
Bcgon:
akrud
Gvnteeae1 ccmes
ie hr r 2 uubr
Seai:Et5oto 1
cnro a
u f 2
We Iet5ccmes
hn
a
uubr
Te Isol hv 7ccmes
hn
hud ae
uubr
Seai:Et6oto 1
cnro a
u f 2
We Iet6ccmes
hn
a
uubr
Te Isol hv 6ccmes
hn
hud ae
uubr
I18N
EN
Seai:Acuthssfiin fns
cnro con a ufcet ud
Gvnteacutblnei $0
ie h con aac s 10
Adtecr i vld
n h ad s ai
Adtemciecnan eog mny
n h ahn otis nuh oe
We teAcutHle rqet $0
hn h con odr euss 2
Te teAMsol dses $0
hn h T hud ipne 2
Adteacutblnesol b $0
n h con aac hud e 8
Adtecr sol b rtre
n h ad hud e eund

HU
#agae h
lnug: u
Fraóöy:Vneé pn asáln
ogtknv a lg éz
zmá
Aenie asáleyne $0
mnybn
zmagelg 10
É akry évne
s
áta réys
É a AMbneeed pn vn
s z T-e lgnő éz a
Aio tljoo kvs $0t
mkr uadns iez 2Akra AMka $0t
ko z T id 2É asál eynee$0
s
zma gelg 8
É akrytkat a AM
s
átá ida z T
ESZKÖZÖK
✱
ÉS KERETRENDSZEREK
.Net: NBehave, NSpec, Concordion
Java: JBehave, Spock, Concordion
JavaScript: Jasmine, Vows (node.js)
PHP: Behat, PHPUnit Story
Python: Behave, Letucce, Concordion
Ruby: RSpec, Cucumber, Concordion
Scala: ScalaTest, Concordion
✱

a nyelvek ABC sorrendben szerepelnek
SCENARIO
A teszt metódus nevek legyenek mondatok
Egy kifejező teszt név nagyon hasznos, ha failel a
teszt
Viselkedést definiáljunk, ne tesztet írjunk
A követelmény viselkedés is
Mindennapi (mindenki számára érthető) nyelven
Az elfogadási kritériumok legyenek futtathatók
Legyen a story olvasmányos
Mi lenne ha?
BDD != TDD
AVAGY MIT TESZTELJÜNK?
BBD » TDD
TDD
test
class under test
method under test
passing / behaving
failing / misbehaving
100% coverage

BDD
example
class we’re describing
valuable behaviour
working, providing value
should it do what I’ve described?
Please, come change my code. I
believe I’ve given you enough
information to do this safely.
PÉLDÁUL...
BEHAT & MINK
SCENARIO
Seai:Cekgnrt tubal
cnro hc eeae hmnis
GvnIa i adrcoy"m"
ie
m n
ietr ig
AdIhv a iptiae"et12_6.n"
n
ae n nu mg ts_0478pg
We Icet nwtubal
hn
rae e hmnis
Te nwycetdtubaleit "etspg
hn el rae hmni xss ts_.n"
Adnwycetdtubaleit "etmpg
n el rae hmni xss ts_.n"
KÓD
<pp
?h
/ FlSseCnetetnsBhtBhtCnetBhtotx;
/ ieytmotx xed eaeaotxeaCnet
casTubaletrsetnsFlSseCnet
ls hmniFaue xed ieytmotx
{
/*
*
*@ie /Ia i adrcoy"["])$
Gvn ^ m n
ietr (^"*"/
*@ie /Ig t adrcoy"["])$
Gvn ^ o o
ietr (^"*"/
*
/
pbi fnto cagDro$ietr){
ulc ucin hneiT(drcoy }
/*
*
*@ie /Ihv a iptiae"["])$
Gvn ^ ae n nu mg (^"*"/
*
/
pbi fnto raFl(fl){
ulc ucin edie$ie }
KÓD
/*
*
*@hn/Icet nwtubal$
We ^ rae e hmnis/
*
/
pbi fnto cetTubal( {
ulc ucin raehmnis) }
/*
*
*@hn/nwycetdtubaleit "["])$
Te ^el rae hmni xss (^"*"/
*@hn/fl eit "["])$
Te ^ie xss (^"*"/
*
/
pbi fnto flEit(fl){
ulc ucin iexss$ie }
}
SHAMELESS SELF PROMO
KÉRDÉSEK?
Szász Zoltán

zoltan at szasz.me
@szaszz
/in/zoltanszasz
READ_IT_LATER.TXT
Business
Behavior
@tastapod @papachrismatts @lunivore
XP teszt alapok
Kent Beck - Extreme Programming
Explained
TDD
SOLID
SRP: Single Responsibility Principle
READ_MORE_LATER.TXT
OCP: Open Closed Principle
LSP Liskov Substitution Principle
ISP: Interface Segregation
Principle
DIP: Dependency Inversion
Principle
Clean Coders
YAGNI: You ain't gonna need it
DRY: Don't Repeat Yourself
KISS: Keep It Simple Stupid
READ_MORE_LATER_2.TXT
FIRST: Fast, Independent, Repetable, Self-validating,
Timely
Magyar Attila - Clean Code slide video
Orcsik Antal - Objektum orientált mérések a
gyakorlatban slide video
Ördög Rafael - Test driven mockery slide video
Robert C. Martin - Clean Code: A Handbook of Agile
Software Craftsmanship
Robert C. Martin - Tiszta kód
Robert C. Martin - The Clean Coder: A Code of
Conduct for Professional Programmers
Robert C. Martin - Túlélőkönyv programozóknak
READ_MORE_LATER_3.TXT
„Betört ablak”-elv
Specifikáció
formális specifikáció
User Story
C3
User Story
On Acceptance criteria for user
stories
DSL
Gherkin - a nyelv
READ_MORE_LATER_4.TXT
Gherkin ~40 nyelven
Given-When-Then
.Net: NBehave, NSpec, Concordion
Java: JBehave, Spock,Concordion
JavaScript: Jasmine, Vows (node.js)
PHP: Behat, PHPUnit Story
Python: Behave, Letucce,
Concordion
Ruby: RSpec, Cucumber,
Concordion
Scala: ScalaTest, Concordion
READ_MORE_LATER_5.TXT
Dan North - Introducing
BDD
Dan North - What’s in a
Story?
BBD » TDD
Behat & Mink
PHP Meetup Budapest
@szaszz /in/zoltanszasz

Mais conteúdo relacionado

Destaque

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Destaque (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Hello BDD @ WebConf/2013