CodeCamp Iasi 10 march 2012 - Cucumber

758 views

Published on

Published in: Economy & Finance, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
758
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

CodeCamp Iasi 10 march 2012 - Cucumber

  1. 1. sâmbătă, 10 martie 12
  2. 2. Agile Functional Specifications Iulian Dogariu 10 March 2012sâmbătă, 10 martie 12
  3. 3. Customers who know EXACTLY what they wantsâmbătă, 10 martie 12
  4. 4. sâmbătă, 10 martie 12
  5. 5. sâmbătă, 10 martie 12
  6. 6. Specifications ?sâmbătă, 10 martie 12
  7. 7. 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
  8. 8. ... and specificationsâmbătă, 10 martie 12
  9. 9. An even better specification y2 =2sâmbătă, 10 martie 12
  10. 10. sâmbătă, 10 martie 12
  11. 11. Specifications CHANGE all the time and, as a result, our software changes all the timesâmbătă, 10 martie 12
  12. 12. Technical Spec Functional spec Source Code Acceptance Test Plansâmbătă, 10 martie 12
  13. 13. Technical Spec Functional spec Source Code Acceptance Test Plansâmbătă, 10 martie 12
  14. 14. 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
  15. 15. sâmbătă, 10 martie 12
  16. 16. Technical Spec Functional spec Source Code Acceptance Test Plansâmbătă, 10 martie 12
  17. 17. Technical Spec Functional spec Source Code Acceptance Test Plansâmbătă, 10 martie 12
  18. 18. 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
  19. 19. 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
  20. 20. 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
  21. 21. 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
  22. 22. Where Cucumber fits in Technical Spec Source Code Functional Acceptance spec Test Plansâmbătă, 10 martie 12
  23. 23. 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
  24. 24. 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
  25. 25. sâmbătă, 10 martie 12
  26. 26. sâmbătă, 10 martie 12
  27. 27. sâmbătă, 10 martie 12
  28. 28. 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
  29. 29. Cucumber Workflow Feature file(s) Gherkin interpreter "Steps" (acceptance test code) Application code under testsâmbătă, 10 martie 12
  30. 30. 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
  31. 31. sâmbătă, 10 martie 12
  32. 32. sâmbătă, 10 martie 12
  33. 33. 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
  34. 34. 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
  35. 35. 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
  36. 36. ... and moresâmbătă, 10 martie 12
  37. 37. sâmbătă, 10 martie 12
  38. 38. Dan North http://dannorth.net Aslak Hellesøy http://www.aslakhellesoy.comsâmbătă, 10 martie 12
  39. 39. JUnit Cucumbersâmbătă, 10 martie 12
  40. 40. sâmbătă, 10 martie 12
  41. 41. http://cukes.info - Official project pagesâmbătă, 10 martie 12
  42. 42. One more thingsâmbătă, 10 martie 12
  43. 43. # 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
  44. 44. sâmbătă, 10 martie 12
  45. 45. A tool for: * Acceptance testing * Requirements description * COMMUNICATIONsâmbătă, 10 martie 12
  46. 46. Questions, pleasesâmbătă, 10 martie 12
  47. 47. Thank you! And please don’t forget the evaluation form :-)sâmbătă, 10 martie 12

×