IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
Intro To Test Driven Development
1. November 16, 2010 NWO-PUG 1
Intro to Test Driven DevelopmentIntro to Test Driven Development
Chris TankersleyChris Tankersley
Joind.in Link: http://joind.in/2347
E-mail: chris@ctankersley.com
Twitter: @dragonmantank
2. November 16, 2010 NWO-PUG 2
Who Are You and Why Are You InWho Are You and Why Are You In
My House?My House?
Chris TankersleyChris Tankersley
Been doing PHP for almost 8 years nowBeen doing PHP for almost 8 years now
Lots of projects no one uses released under theLots of projects no one uses released under the
BSD licenseBSD license
Contributer to the Habari ProjectContributer to the Habari Project
3. November 16, 2010 NWO-PUG 3
What is Test Driven Development?What is Test Driven Development?
„„Test-driven development (TDD) is a softwareTest-driven development (TDD) is a software
development process that relies on the repetitiondevelopment process that relies on the repetition
of a very short development cycle: first theof a very short development cycle: first the
developer writes a failing automated test case thatdeveloper writes a failing automated test case that
defines a desired improvement or new function,defines a desired improvement or new function,
then produces code to pass that test and finallythen produces code to pass that test and finally
refactors the new code to acceptable standards.”refactors the new code to acceptable standards.”
http://en.wikipedia.org/wiki/Test-driven_development
4. November 16, 2010 NWO-PUG 4
Why Do TDD?Why Do TDD?
●
Considered a Best Practice amongst almost allConsidered a Best Practice amongst almost all
languageslanguages
●
Provides confidence in the codeProvides confidence in the code
●
Provides confidence in the requirementsProvides confidence in the requirements
●
Proves remediationProves remediation
5. November 16, 2010 NWO-PUG 5
TDD is EasyTDD is Easy
1)1)Write a TestWrite a Test
2)2)Watch it FailWatch it Fail
3)3)Write CodeWrite Code
4)4)TestTest
5)5)Repeat 3 and 4 until PassingRepeat 3 and 4 until Passing
6)6)Repeat AllRepeat All
6. November 16, 2010 NWO-PUG 6
Our Sample ApplicationOur Sample Application
●
Create an application to test basic math skillsCreate an application to test basic math skills
●
We need a Calculator to add numbersWe need a Calculator to add numbers
●
Needs to handle bad inputNeeds to handle bad input
●
We need a Tutor class to test answersWe need a Tutor class to test answers