View
16
Download
0
Category
Preview:
Citation preview
12/16/15
1
TDR&TDDTest-Driven{Requirements&Development}ByMikeRieser (email:mike@mrieser.com)
ENGINEERING PRACTICES
“PeoplehavetoldmethattheyseeScrumasthemanagementapproachtoagiledevelopmentandXPastheengineeringpracticesthatmakeiteffective,bothbondedtogetherbycomplimentarypracticesandgoals.”
– KenSchwaber
12/16/15
2
ScrumforProcess, ExtremeProgramming(XP)forPractices
“Accordingly,wheneverIhaveasituationinwhichsoftwareisbeingdeveloped,Scrumisbeingused,andtheengineeringpracticesaresubstandard,IalsocallforXPtobeimplemented.”
– KenSchwaber
#3
Scrum’s InfluenceonExtremeProgramming(XP)
From: Kent Beck To: Jeff Sutherland <jsutherland>
Reply: 70761.1216@compuserve.com
Date: Mon, 15 May 1995 18:01:15 -0400 (EDT)
Subj: HBR paper
_____________________________________________________Isthere agoodplace togetreprints ofthe SCRUM paper fromHBR? I'vewritten patterns for something verysimilar andIwanttomakesure Istealasmanyideas aspossible.
Kent
#4
12/16/15
3
MATURINGPRACTICES
DiscussionTeamsnewtoScrumtypically startbyputtingeverythinginprogressandtreatingtheiterationlikeamini-waterfall.
Howhaveyouseenteamsmature inthewaytheyapproachandaccomplish theirwork?
12/16/15
4
SkillMaturityModelsAgile teamsmatureintheir skillsandpractices:• DreyfusModel: Novice toExpert.• MartialArts: Shu-Ha-Ri.• Meilir Page-Jones: InnocenttoResearcher.
NoviceAgileTreat anIteration likeamini-waterfall. Allstories putin flight atonce.QAgetssqueezed atthe
endhaving totesteverything thenight before the demo.
12/16/15
5
QAPlightTheTester isattheendoftheprocessandmayhavequestions.
?
?
AdvancedBeginnerTeamstarts completing stories earlier, butstill approaches eachstory inatraditional fashion.
12/16/15
6
StevenCoveytip: “Beginwith theendinmind.”Let’sisolateaUser Storyandthinkaboutit.
“Beginwiththeendinmind.”WhatifwebeganwithQATesting?
12/16/15
7
QATestsandRequirements atthestart.Thiswrapsalotofthingsaround.NoticewheretheBAandQA endup?
Separate outtheDevtasks.
12/16/15
8
Isolateeacharea.
Rearrange theDevtasks. Codemovesearlier.
12/16/15
9
We’llredirect theflow.
AnalysisfeedsTests.FromTestswegostraight toCode.
12/16/15
10
Let’snameeachofthesekeyareas.
Test-DrivenRequirements +Test-DrivenDevelopment
12/16/15
11
Mature teamwithmature practicesPracticingTest-DrivenRequirementswithTest-DrivenDevelopment
TEST-DRIVENREQUIREMENTS
“Anexamplewouldbehandyrightaboutnow.”– BrianMarick
12/16/15
12
TestTablesarebestdonecollaboratively!
SoftwareRequirements asaTable“...anysoftwareprogramcanbethoughtofasatablethatmapsprograminputstotheircorrespondingcorrectoutputs.Thischaracterizationofprogrammingassumesafinitenumberoffiniteinputs,whichisfairforpracticalpurposes” 27
July 2001 issue of ACM Software Engineering Notes, J. P. Lewis
12/16/15
13
WorldofWarcraftCharacterMovementCharacter MovementCharacterName
CharacterLocation
ObjectLocation Move Location? #Comment
Operandi (0, 0,0) - Forward (1,0,0) Unhinderedmovement
Operandi (0,0, 0) (-1, 0,0) Backward (0,0,0) Blockedmovement
Persona!
ATMWithdrawCashTestTableWithdraw Cash
ATM CashAccountBalance
RequestAmount Result?
ATMCash?
AccountBalance? #Comment
$1,000 $5,000 $100 OK $900 $4,900 Happy
$1,000 $1,000 $1,000 OK 0 0 Boundary
$100 $5,000 $200 ERROR $100 $5,000 InsufficientATMcash
$1,000 $100 $200 ERROR $1,000 $100 Insufficientacct balance
$1,000 -$100 $200 ERROR $1,000 -$135 Overdraftfee!
12/16/15
14
Gherkin– Given-When-ThenGiven anAccountwitha$5,000balanceAnd theATMwith$1,000cash
When thePatronwithdraws$100cash
Then theAccountbalance is$4,900And theATMhas$900cash
CommonTools• Fit(orSlim)andFitNesse (JavaorC#)• SpecFlow (C#)• Jbehave (Java)• Cucumber (Ruby)• Concordian• Nominations?
12/16/15
15
Discussion• AnyonehavestoriesofTest-DrivenRequirementssparkingcollaboration onteams?
• When’sthebesttimetohavetheteamcreatethetests?
TEST-DRIVENDEVELOPMENT
12/16/15
16
SoftwareDevelopment ProcessDependencies
34
Waterfall
UpfrontRequirements
Upfront Design
Agile
Evolutionary Design
Refactoring
Automated DeveloperTests
TestFirst
TestAfter
Test-AfterApproach
TraditionalWay– TestAfter• 1daytothinkanddesign• 2daystowritethecode• Ohyeah,2daystowritetheunittests
DesignJ
CodeK
UnitTestL
35
12/16/15
17
Test-FirstApproach
TDDWay– TestFirst• Takesaboutthesametimeasjustdesignandcodedidbefore• UnitTestsseemingly forfree– how?
Writeatest
KMakeitpass
JMakeitright
J
36
WhatisTDD?• DeveloperPractice• Test-FirstProgramming• IncrementalDesign• One testatatime• TDDdoesunittestingbutunittestingisnotnecessarilyTDD
12/16/15
18
WhatTDDisNot!• Writing allthetests beforethecode• NotQATesting• Not IntegrationTesting
WhatisRed?Afailing testislikeahuntinglicense tochangeproductioncode.• Enhancements – addatesttoaddnewfunctionality.
• Defects – reproduce thebugasafailingtest.
Onlyintroduceasmuchofatestasyoucangettogreen insay,5mins.
12/16/15
19
WhatisGreen?GettoGreenquickly!ObviousImplementation – ifyouknowwhattodo,justdoit!Fake It!– whenyoudon’tuseaconstant!
WhatisRefactor?• Workincrementally.• BeabletoshowGreen aftereachchange.• Removeduplication.• CleanasyouGo!
12/16/15
20
Refactor– whatdoyoumean?if ( ... ) {
...i = i + 1;
} else {...i = i + 1;
}
if ( … ) {…
} else {…
}
i = i + 1;
if ( ... ) {...
} else {...
}
i = i + 1;
WhatisIntegrate??• Integrateasfrequentlyaspossible.• Maynotbecomplete,butifdone-enough,shareit.• (ItypicallyavoidcheckinginFakes.)
12/16/15
21
Test-Firstvs Test-AfterTest-First
• Thetestsgetwritten.• Testablecodeisgenerallyflexiblecode.
• Lowercoupling• Highercohesion• AllowsRefactoring• Confidence
Test-After
• Sometimestheunittestsget“skipped.”
• Teststhatstartfromawizardaregenerallyprettypoor.
WhatAreUnitTests?• Testswhichhaveaspecific focuswhichcallamethod(orfunction).
• Verify thatthe requirements arebeingmetbythecodewhentestedinisolation.
• “Likeacompiler” forthebusiness requirements.
12/16/15
22
WhatUnitTestsareNOT!
BenefitsofTDD?• Testfirstismorefunthattestafter• UnitTestsactuallygetwritten• Producestestabledesigns• Thinkoutside-in, firstabouthowtouse,thenabouthowtodoit• GoodunitteststhatsupportRefactoring• RequirementsClarification&Understanding• Confidence (nofear)• Solutions thatfitlikeahandinaglove• Version1.0codethatyouarehappywith• ReducesDefects
12/16/15
23
TDD– “Rediscovered”byKentBeck“TotheunknownauthorofthebookwhichIreadasaweird12-yearoldthatsuggestedyoutypeintheexpectedoutputtapefromarealinputtape,thencodeuntiltheactualresultsmatchedtheexpected result,thankyou,thankyou,thankyou.”
– KentBeck(Test-DrivenDevelopmentByExample)
THEENDQuestions?
Recommended