Agile DC 2016 Behavior Driven Development Workshop
-
Upload
craeg-strong -
Category
Software
-
view
95 -
download
0
Transcript of Agile DC 2016 Behavior Driven Development Workshop
1
Behavior Driven DevelopmentWorkshop
Craeg Strong CTO, Ariel Partners
October 24, 2016Washington, DC
©CopyrightArielPartners2016*[email protected]((646)467-7394
2
Software Development since 1988
Large Commercial & Government Projects
Agile Coach / DevOps Engineer
Kanban Trainer / SpecFlow Trainer
Performance & Scalability Architect
Certified Ethical Hacker
New York & Washington DC Area
CTO,ArielPartnersAKT,CSM,CSP,CSD,CSPO,PSM,ITILv3,PMI-ACP,PMP,LeSS,SAFe
@ckstrong1
CraegStrong
©CopyrightArielPartners2016*[email protected]((646)467-7394
3
Agenda
• Context &Background• BenefitsofBDD• GoodvsBadGherkinDemonstration• BadGherkinTeam Review&Discussion• Whirlwind TourofTools&Reports• GherkinWritingWorkshop• GroupDiscussion
©CopyrightArielPartners2016*[email protected]((646)467-7394
4
SuppliesNeeded
1. 2+RollsofScotchTransparentTape2. 6+PadsofLargeSizePost-ItNotes3. ADozenormoreSharpies4. 1-2Post-ItSelf-StickEaselPads25”x30.5”
©CopyrightArielPartners2014*[email protected]((646)467-7394
5
WhereDoesBDDFitIn?
©CopyrightArielPartners2016*[email protected]((646)467-7394
UsefulTechniquesStoryMapping
BDD:SpecificationByExampleImpactMapping
Visioning/IdeationWorkshops
GOOTB MockupsWireframes
JourneyMapping
6
WhenDoOrganizationsSwitchToBDD?
• Newtoscrum,needhelpwithunderstandinghowtocreateusefulAcceptanceTestCriteria
• ConvertingalegacyMicrosoftVBapplicationto.NET• Governmentprojectwithoutenoughtesting,needtobeefuptestingcapabilities
• Mostlymanualtesting,spreadsheets,lookingforabetterway• AutomatedGUITestsBrittle,HardToMaintain
©CopyrightArielPartners2016*[email protected]((646)467-7394
7
WhatProblemsCanBDDSolve?qEnsure what is to be delivered is actually requiredqEnsure what is to be delivered is valuable to the businessqEnsure what is to be delivered is within the agreed scope of
functionalityqEnsure what is to be delivered is well understood by the team
©CopyrightArielPartners2016*[email protected]((646)467-7394
ü Clearly specify the required behavior of each software component ü in everyday common business language ü that anyone in the team (including business stakeholders) can understandü And then enforce those rules via tests
How?
8
WhoIsInvolved?TheThreeAmigos
©CopyrightArielPartners2016*[email protected]((646)467-7394
public void CalculateDiscount(Order order){if (order.Customer.IsNew)order.FinalAmount = Math.Round(order.Total * 9/10);
}
Registeras“bart_bookworm”Goto“/catalog/search”Enter“ISBN-0955683610”Click“Search”Click“AddtoCart”Click“ViewCart”Verify“Subtotal”is“$33.75”
Wewouldliketoencouragenewuserstobuyinourshop.Thereforeweoffer10%discountfortheirfirstorder.
Analyst Developer Tester
9
SpecificationWorkshops
©CopyrightArielPartners2016*[email protected]((646)467-7394
Giventheuserhasnotorderedyet
WhentheuseraddsabookwiththepriceofEUR37.5intotheshoppingcart
Thentheshoppingcartsub-totalisEUR33.75.
Wewouldliketoencouragenewuserstobuyinourshop.Thereforeweoffer10%discountfortheirfirstorder.
Analyst Developer Tester
Gherkin
10
Gherkin:TheLanguageofBDD
©CopyrightArielPartners2016*[email protected]((646)467-7394
ScenarioGiven [Context]And[MoreContext]
When(<role>does)[Action]And[OtherAction]
Then(<role>shouldsee) [Outcome]And[MoreOutcomes]
Scenarios=
TestCases=
AcceptanceCriteria
12
BadversusGoodGherkin
©CopyrightArielPartners2016*[email protected]((646)467-7394
HappyPathShouldbeFirst
Boundaryconditiondoesnotmatchscenario
Showme,don’ttellme.Shouldbeanexample
GUIDisplayDetailmakesthisbrittle.Whatifwechangeittoabarchart?
Thisdataisalreadygrouped.Usetheuser’slanguagenottechnicallanguage
MoreGUIDetails,notnecessary
?WhyDifferent?
14
CharacteristicsofGood GherkinSpecifications
• UseDomainLanguage(ProblemSpace)notTechnicalLanguage(SolutionSpace)
• Tangible,notAbstract• Explicit,notImplicit• No Extraneousinformation• HumanReadable,no“magicnumbers”• AvoidGUI-Specificterms(e.g.“button”,“screen”,“click”)• LookForReusablePhrases
©CopyrightArielPartners2016*[email protected]((646)467-7394
15
ScenarioOutlineStyle-Gherkin
©CopyrightArielPartners2016*[email protected]((646)467-7394
Feature: Shipping cost calculation
Scenario Outline: Calculate shipping costsGiven I have <books> books in my basketAnd my shipping address is in <region>When I start the checkout processThen the shipping costs should be EUR <cost>
Examples:| case | books | region | cost || single book to EU | 1 | Europe | 7 || two books to EU | 2 | Europe | 9 || single book to US | 1 | US | 12 |
@edge-case
Examples: Edge cases| case | books | region | cost || too many books | 10000 | Europe | 20005 || zero books | 0 | Europe | 0 |
20
BDDcuts theGordianknot
©CopyrightArielPartners2016*[email protected]((646)467-7394
UnitTestsAsNeeded
AutomatedAcceptanceTests(BDD)
AutomatedGUITests
ManualExploratoryTesting
21
FeaturesVersusUserStories
©CopyrightArielPartners2016*[email protected]((646)467-7394
1.ManualEntryofEmail
2.Dropdown
4.Type-Ahead
3.Don’tShowMyEmail
22
FeatureFile
BDDWithSpecFlow1.WriteFeature
StepDefinitions2.GenerateTemplate
3.FillInCode
©CopyrightArielPartners2016*[email protected]((646)467-7394
23
FunctionalCoverageReport
q All system functions expressed as features, split into user storiesq All user stories have acceptance criteriaq Each criterion translated to an automated test using structured
English (Gherkin)q Customized report matches epics and user stories to automated
acceptance testsq Test fails unless software is implemented correctly
LinkstoFeatureDocumentation
GeneratedviaPickles
©CopyrightArielPartners2016*[email protected]((646)467-7394
24
GeneratingDocumentationFromSpecifications
©CopyrightArielPartners2016*[email protected]((646)467-7394
26
DifferentflavorsofBDD
©CopyrightArielPartners2016*[email protected]((646)467-7394
ExternalSpecificationMaintainedOutsideof
CodeBase
CodeBase
Application
ExcelSheet WikiPage
TextualSpecificationMaintainedWithin
CodeBase
CodeBase
SpecificationCapturedDirectlyInSourceCode
CodeBase
27
GherkinExercise:TeamOne
©CopyrightArielPartners2016*[email protected]((646)467-7394
As a userI want to input my feedbackSo that I can recognize a co-worker for their actions
Acceptance Criteria• Both sender and receiver email must be filled in• One Corporate value (e.g. Integrity, Commitment, Courage, Excellence) must be filled in• A short, optional description may be filled in• I need to be able recognize someone even if they are not registered with the recognition system
Key Examples• [email protected] recognizes an existing user [email protected] for Integrity• [email protected] recognizes a new user [email protected] for Commitment
Create Recognition
29
GherkinExercise:TeamTwo
©CopyrightArielPartners2016*[email protected]((646)467-7394
As a managerI want the system to limit the number of times per week a user can recognize a co-workerSo that a recognition is seen as valuable
Acceptance Criteria• To send a recognition, both sender and receiver email must be filled in• To send a recognition, one Corporate value (e.g. Integrity, Commitment, Courage, Excellence) must be filled in• For each recognition, a short, optional description may be filled in• If a user has sent three recognitions this week, system should prevent user from entering a fourth
Key Examples
Limit Recognitions Per Week
Sender Receiver Corporate Value Date Result
[email protected] [email protected] Commitment Monday 17 Oct 2016 ok
[email protected] [email protected] Integrity Wed 19 Oct 2016 ok
[email protected] [email protected] Respect Thur 20 Oct 2016 ok
[email protected] [email protected] Courage Fri 21 Oct 2016 error
31
GherkinExercise:TeamThree
©CopyrightArielPartners2016*[email protected]((646)467-7394
As an administratorI want to maintain the set of corporate values for which a user can recognize a peerSo that our corporate culture is aligned with the values we espouse
Acceptance Criteria• Each corporate value consists of a one or two word title and a brief description• There must never be less than two corporate values• If a previously-existing corporate value is removed, existing recognitions are unaffected, but no new recognitions can be added
with the removed corporate value
Key Examples
Maintain Corporate Values
Corporate Value Description
Integrity Always act honestly, ethically, and do the right thing even when it hurts
Commitment Committed to the long term success and happiness of our customers, our people, and our partners
Courage To take on difficult challenges, to accept new ideas, to accept incremental failure
Excellence Always strive to exceed expectations and continuously improve
33
GherkinExercise:TeamFour
©CopyrightArielPartners2016*[email protected]((646)467-7394
As a userI want to see the most recent recognitionsSo that I can stay informed of the recognitions my peers are receivingAcceptance Criteria• Home page should display a list of all recognitions in the system• Each recognition should list the sender email, receiver email, corporate value, and date sent• The list of recognitions should show the most recent first, like the facebook feed • A user should be able to sort any column• A user should be able to show only recognitions for a particular corporate value (filter by corporate value)
Key Examples
Recognition Feed
Sender Receiver Corporate Value Date
[email protected] [email protected] Excellence 10/12/2016
[email protected] [email protected] Excellence 9/27/2016
[email protected] [email protected] Courage 10/22/2016
[email protected] [email protected] Commitment 6/1/2016
35
TeamDiscussions,Q&A
©CopyrightArielPartners2016*[email protected]((646)467-7394
CraegStrongSavantFinancialTechnologies,Inc.d/b/aArielPartnersCell:(917)[email protected]@arielpartners
ThankYou!
HelpfulLinksGherkinDocumentation:http://docs.behat.org/en/v2.5/guides/1.gherkin.htmlCucumber(Java,PHP,Ruby,etc):https://cucumber.io/Cucumber(JavaScript):https://www.npmjs.com/package/cucumberSpecflow (.NET):http://www.specflow.org/PicklesDocumentation:http://www.picklesdoc.com/CucumberJS Reports:https://www.npmjs.com/package/cucumber-html-reporter…manymore...
36
AdvantagesofBDDApproach
©CopyrightArielPartners2016*[email protected]((646)467-7394
Improves Software Quality
q Helps develop frugal, effective and testable softwareq Answers: what functions are well-covered? Where do we have exposure?
Makes Writing Tests Easier
q many convenience functions q pre-integrated with powerful libraries like NUnit and Selenium
Encourages Collaboration
q Encourages tester, analyst and developer to sync upq Captures information that might otherwise be lost
Facilitates Communication
q Way for Product Owners to provide concrete examplesq Easy to define boundary conditions
Documentation and Reporting
q Requirements Traceability? Yup. q Functional Coverage? Yup.
Are we building right thing?
q Did we “answer the mail”?q Validates that the software meets the requirements