Upcoming SlideShare
×

Like this presentation? Why not share!

# CodeCamp Iasi 10 march 2012 - Cucumber

## on Mar 13, 2012

• 707 views

### Views

Total Views
707
Views on SlideShare
707
Embed Views
0

Likes
0
6
0

No embeds

### Report content

• Comment goes here.
Are you sure you want to

## CodeCamp Iasi 10 march 2012 - CucumberPresentation Transcript

• sâmbătă, 10 martie 12
• Agile Functional Speciﬁcations Iulian Dogariu 10 March 2012sâmbătă, 10 martie 12
• Customers who know EXACTLY what they wantsâmbătă, 10 martie 12
• sâmbătă, 10 martie 12
• sâmbătă, 10 martie 12
• Speciﬁcations ?sâmbătă, 10 martie 12
• Algorithm... y = 1. 4 1 4 2 02.00 00 00 00 02 1*1 <= 2 < 2*2 x = 1 01 y = x*x = 1*1 = 1 01 00 24*4 <= 100 < 25*5 x = 4 00 96 y = (20+x)*x = 24*4 = 96 04 00 281*1 <= 400 < 282*2 x = 1 02 81 y = (280+x)*x = 281*1 = 281 01 19 00 2824*4 <= 11900 < 2825*5 x = 4 01 12 96 y = (2820+x)*x = 2824*4 = 11296 06 04 00 28282*2 <= 60400 < 28283*3 x = 2sâmbătă, 10 martie 12
• ... and speciﬁcationsâmbătă, 10 martie 12
• An even better speciﬁcation y2 =2sâmbătă, 10 martie 12
• sâmbătă, 10 martie 12
• Speciﬁcations CHANGE all the time and, as a result, our software changes all the timesâmbătă, 10 martie 12
• Technical Spec Functional spec Source Code Acceptance Test Plansâmbătă, 10 martie 12
• Technical Spec Functional spec Source Code Acceptance Test Plansâmbătă, 10 martie 12
• package com.bigbank; public class AccountTest { @org.junit.Test public void testAccountDeposit() { Account account = new Account(10); account.deposit(20); assertEquals(30, account.getBalance()); } }sâmbătă, 10 martie 12
• sâmbătă, 10 martie 12
• Technical Spec Functional spec Source Code Acceptance Test Plansâmbătă, 10 martie 12
• Technical Spec Functional spec Source Code Acceptance Test Plansâmbătă, 10 martie 12
• Feature: Bank deposit In order to attract funds to my bank As a banker I want to let customers deposit money Scenario: Depositing money raises the balance Given an account with balance €10 When customer deposits €20 into the account Then the balance should be €30sâmbătă, 10 martie 12
• Feature: Bank deposit In order to attract funds to my bank As a banker I want to let customers deposit money Scenario: Depositing money raises the balance Given an account with balance €10 When customer deposits €20 into the account Then the balance should be €30 If only we could execute THIS ...sâmbătă, 10 martie 12
• Feature: Bank deposit In order to attract funds to my bank As a banker I want to let customers deposit money Scenario: Depositing money raises the balance Given an account with balance €10 When customer deposits €20 into the account Then the balance should be €30sâmbătă, 10 martie 12
• Feature: Bank deposit In order to attract funds to my bank As a banker I want to let customers deposit money Scenario: Depositing money raises the balance Given an account with balance €10 When customer deposits €20 into the account Then the balance should be €30 Yes, this is a Cucumber executable specsâmbătă, 10 martie 12
• Where Cucumber ﬁts in Technical Spec Source Code Functional Acceptance spec Test Plansâmbătă, 10 martie 12
• Feature: Bank deposit In order to attract funds to my bank As a banker I want to let customers deposit money Scenario: Depositing money raises the balance Given an account with balance €10 When customer deposits €20 into the account Then the balance should be €30 Scenario: Reject deposits of negative amounts Given an account with balance €10 When I deposit €-5 Then the balance should be €10sâmbătă, 10 martie 12
• Feature: Bank deposit In order to attract funds to my bank As a banker I want to let customers deposit money Scenario: Depositing money raises the balance Given an account with balance €10 When customer deposits €20 into the account Then the balance should be €30 Scenario: Reject deposits of negative amounts Given an account with balance €10 When I deposit €-5 Then the balance should be €10sâmbătă, 10 martie 12
• sâmbătă, 10 martie 12
• sâmbătă, 10 martie 12
• sâmbătă, 10 martie 12
• Feature: A relevant name In order to achieve <an important business goal> As a <stakeholder> I want to <do something with the software> Scenario: Whatever I’m verifying Given a widget And a user When the user pushes the widget Then I expect the widget should widge Scenario: Something else I’m verifying Given [...]sâmbătă, 10 martie 12
• Cucumber Workﬂow Feature file(s) Gherkin interpreter "Steps" (acceptance test code) Application code under testsâmbătă, 10 martie 12
• Feature: Interest calculation In order to attract funds to my bank As a banker I want to compensate customers for depositing Scenario: Monthly interest Given an account with balance €100 And the annual interest rate is 6.00% And the start date is 01.01.2012 When the date is 01.02.2012 Then the interest paid should be €0.49sâmbătă, 10 martie 12
• sâmbătă, 10 martie 12
• sâmbătă, 10 martie 12
• Feature: Interest calculation [...] Scenario: Monthly interest Given an account with balance €1000 And the annual interest rate is 6.00% And the start date is 01.01.2012 When the date is 01.02.2012 Then the interest paid should be €4.87 Scenario: Quarterly interest Given an account with balance €1000 And the annual interest rate is 6.00% And the start date is 01.01.2012 When the date is 01.04.2012 Then the interest paid should be €14.67sâmbătă, 10 martie 12
• Feature: Interest calculation [...] Scenario Outline: Monthly interest Given an account with balance €1000 And the annual interest rate is <rate>% And the start date is 01.01.2012 When the date is <now> Then the interest paid should be €<interest> Examples: | now | rate | interest | | 01.02.2012 | 6.00 | 4.87 | | 01.04.2012 | 6.00 | 14.67 |sâmbătă, 10 martie 12
• Feature: Interest calculation [...] Scenario Outline: Monthly interest Given an account with balance €1000 And the annual interest rate is <rate>% And the start date is 01.01.2012 When the date is <now> Then the interest paid should be €<interest> Examples: | now | rate | interest | | 01.02.2012 | 6.00 | 4.87 | | 01.02.2012 | 3.00 | 2.44 | | 01.03.2012 | 6.00 | 9.76 | | 01.04.2012 | 6.00 | 14.67 |sâmbătă, 10 martie 12
• ... and moresâmbătă, 10 martie 12
• sâmbătă, 10 martie 12
• Dan North http://dannorth.net Aslak Hellesøy http://www.aslakhellesoy.comsâmbătă, 10 martie 12
• JUnit Cucumbersâmbătă, 10 martie 12
• sâmbătă, 10 martie 12
• http://cukes.info - Ofﬁcial project pagesâmbătă, 10 martie 12
• One more thingsâmbătă, 10 martie 12
• # language: ro Funcționalitate: Depozit bancar Pentru a atrage fonduri În calitate de bancher Doresc ca clienții să poată depune bani în cont Scenariu: Depunerea în cont crește soldul Dat fiind un cont cu soldul €10 Când depun €20 în cont Atunci soldul trebuie să fie €30 Scenariu: Respingerea depunerilor de sume negative Dat fiind un cont cu soldul €10 Când depun €-5 în cont Atunci soldul trebuie să fie €10sâmbătă, 10 martie 12
• sâmbătă, 10 martie 12
• A tool for: * Acceptance testing * Requirements description * COMMUNICATIONsâmbătă, 10 martie 12
• Questions, pleasesâmbătă, 10 martie 12
• Thank you! And please don’t forget the evaluation form :-)sâmbătă, 10 martie 12