Posts Tagged ‘TDD’
Agile Vancouver Tech Talk #2 - TDD vs BDD
Last Monday night, Skye and I hosted the second Agile Vancouver tech talk. This month’s topic was test-driven development (TDD) vs. behaviour-driven development (BDD). The goal of the session was to give participants some hands-on experience with TDD and a bit of exposure to BDD. Participants were encouraged to bring laptops to the session if they had them or pair/partner up with others if they didn’t.
About 50 participants showed up for the session. Most people worked in Java using JUnit (with one pair using TestNG), another handful used C# (using NUnit) and one group worked in Perl and Python. I wrote my tests using JBehave and showed my solution on the projector to give beginners a bit of a jump start.
For the problem, I built some scenarios from my weekend’s trip to the grocery store. Participants were encouraged to write a solution for calculating the total of a shopping receipt from a list of items. I presented the following 10 scenarios:
- 1 x EnviroKidz Waffles - $3.79
- 2 x Unsalted Rice Cakes - $2.99
- 1.16kg Broccoli @ 2.82/kg
- 1 x Happy Planet Strawberry Banana Juice - $3.50 + $0.20 Deposit +
$0.03 Enviro fee -
- 1. 1 x EnviroKidz Waffles - $3.79
- 2 x Unsalted Rice Cakes - $2.99
- 1.16kg Broccoli @ 2.82/kg
- Same as 5. but with a $0.05 No plastic bag discount
- 2 x Amy’s Organic Soup - $2.99 / $2.79 for Club members (Club #000104991)
- Calculate frequent shopper points for previous order, where new points = floor(total * 3)
- Calculate new total of frequent shopper points for the previous scenario. Customer Club #000104991 currently has 933 points.
- Non-groceries have 5% GST applied. Calculate the total for:
- 1 x EnviroKidz Waffles - $3.79
- 1 x Economist - $7.50
We spent an hour working on coding up the scenarios, where most participants made it up to scenario #5. This was followed by 30 minutes of discussion where participants presented their code. The most interesting solution IMO was produced by the Perl group who wrote a simple Regex parser for the items and started implementing a wiki-style DSL for specifying test scenarios.
On the whole, I think that the session went quite well, and most participants enjoyed having the opportunity to sit down and directly try out TDD. I think that we will try to do more hands-on sessions for subsequent tech-talk gatherings, potentially building on what we worked on in this session.
If you attended Monday night’s session and would like to post your solution to the scenarios, please feel free to leave a comment on this post linking to your code. I intend to post my solution for these scenarios at some point soon.
Tags: agile, agile vancouver, BDD, TDD, tech talk
Filed under agile :
Comments (0) :
Mar 14th, 2008