CodeCamp Iasi 10 march 2012 - Cucumber

47
sâmbătă, 10 martie 12

description

 

Transcript of CodeCamp Iasi 10 march 2012 - Cucumber

Page 1: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 2: CodeCamp Iasi 10 march 2012 - Cucumber

Agile Functional Specifications

Iulian Dogariu10 March 2012

sâmbătă, 10 martie 12

Page 3: CodeCamp Iasi 10 march 2012 - Cucumber

Customers who knowEXACTLY

what they want

sâmbătă, 10 martie 12

Page 4: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 5: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 6: CodeCamp Iasi 10 march 2012 - Cucumber

Specifications ?

sâmbătă, 10 martie 12

Page 7: CodeCamp Iasi 10 march 2012 - Cucumber

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 = 2

Algorithm...

sâmbătă, 10 martie 12

Page 8: CodeCamp Iasi 10 march 2012 - Cucumber

... and specification

sâmbătă, 10 martie 12

Page 9: CodeCamp Iasi 10 march 2012 - Cucumber

y2 = 2

An even better specification

sâmbătă, 10 martie 12

Page 10: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 11: CodeCamp Iasi 10 march 2012 - Cucumber

SpecificationsCHANGE

and, as a result, our software changes all the time

all the time

sâmbătă, 10 martie 12

Page 12: CodeCamp Iasi 10 march 2012 - Cucumber

Source CodeFunctional

spec

AcceptanceTest Plan

Technical Spec

sâmbătă, 10 martie 12

Page 13: CodeCamp Iasi 10 march 2012 - Cucumber

Source CodeFunctional

spec

AcceptanceTest Plan

Technical Spec

sâmbătă, 10 martie 12

Page 14: CodeCamp Iasi 10 march 2012 - Cucumber

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

Page 15: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 16: CodeCamp Iasi 10 march 2012 - Cucumber

Source CodeFunctional

spec

AcceptanceTest Plan

Technical Spec

sâmbătă, 10 martie 12

Page 17: CodeCamp Iasi 10 march 2012 - Cucumber

Source CodeFunctional

spec

AcceptanceTest Plan

Technical Spec

sâmbătă, 10 martie 12

Page 18: CodeCamp Iasi 10 march 2012 - Cucumber

Feature: Bank depositIn order to attract funds to my bankAs a bankerI want to let customers deposit money

Scenario: Depositing money raises the balanceGiven an account with balance €10When customer deposits €20 into the accountThen the balance should be €30

sâmbătă, 10 martie 12

Page 19: CodeCamp Iasi 10 march 2012 - Cucumber

Feature: Bank depositIn order to attract funds to my bankAs a bankerI want to let customers deposit money

Scenario: Depositing money raises the balanceGiven an account with balance €10When customer deposits €20 into the accountThen the balance should be €30

If only we could execute THIS ...sâmbătă, 10 martie 12

Page 20: CodeCamp Iasi 10 march 2012 - Cucumber

Feature: Bank depositIn order to attract funds to my bankAs a bankerI want to let customers deposit money

Scenario: Depositing money raises the balanceGiven an account with balance €10When customer deposits €20 into the accountThen the balance should be €30

sâmbătă, 10 martie 12

Page 21: CodeCamp Iasi 10 march 2012 - Cucumber

Feature: Bank depositIn order to attract funds to my bankAs a bankerI want to let customers deposit money

Scenario: Depositing money raises the balanceGiven an account with balance €10When customer deposits €20 into the accountThen the balance should be €30

Yes, this is a Cucumber executable specsâmbătă, 10 martie 12

Page 22: CodeCamp Iasi 10 march 2012 - Cucumber

Source Code

Functionalspec

AcceptanceTest Plan

Technical Spec

Where Cucumber fits in

sâmbătă, 10 martie 12

Page 23: CodeCamp Iasi 10 march 2012 - Cucumber

Feature: Bank depositIn order to attract funds to my bankAs a bankerI want to let customers deposit money

Scenario: Depositing money raises the balanceGiven an account with balance €10When customer deposits €20 into the accountThen 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 €10

sâmbătă, 10 martie 12

Page 24: CodeCamp Iasi 10 march 2012 - Cucumber

Feature: Bank depositIn order to attract funds to my bankAs a bankerI want to let customers deposit money

Scenario: Depositing money raises the balanceGiven an account with balance €10When customer deposits €20 into the accountThen 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 €10

sâmbătă, 10 martie 12

Page 25: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 26: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 27: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 28: CodeCamp Iasi 10 march 2012 - Cucumber

Feature: A relevant nameIn order to achieve <an important business goal>As a <stakeholder>I want to <do something with the software>

Scenario: Whatever I’m verifyingGiven a widgetAnd a userWhen the user pushes the widgetThen I expect the widget should widge

Scenario: Something else I’m verifyingGiven [...]

sâmbătă, 10 martie 12

Page 29: CodeCamp Iasi 10 march 2012 - Cucumber

Cucumber Workflow

Feature file(s) Gherkin interpreter

Application codeunder test

"Steps" (acceptance test code)

sâmbătă, 10 martie 12

Page 30: CodeCamp Iasi 10 march 2012 - Cucumber

Feature: Interest calculationIn order to attract funds to my bankAs a bankerI want to compensate customers for depositing

Scenario: Monthly interestGiven an account with balance €100And the annual interest rate is 6.00%And the start date is 01.01.2012When the date is 01.02.2012Then the interest paid should be €0.49

sâmbătă, 10 martie 12

Page 31: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 32: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 33: CodeCamp Iasi 10 march 2012 - Cucumber

Feature: Interest calculation[...]

Scenario: Monthly interestGiven an account with balance €1000And the annual interest rate is 6.00%And the start date is 01.01.2012When the date is 01.02.2012Then the interest paid should be €4.87

Scenario: Quarterly interestGiven an account with balance €1000And the annual interest rate is 6.00%And the start date is 01.01.2012When the date is 01.04.2012Then the interest paid should be €14.67

sâmbătă, 10 martie 12

Page 34: CodeCamp Iasi 10 march 2012 - Cucumber

Feature: Interest calculation[...]

Scenario Outline: Monthly interestGiven an account with balance €1000And the annual interest rate is <rate>%And the start date is 01.01.2012When 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

Page 35: CodeCamp Iasi 10 march 2012 - Cucumber

Feature: Interest calculation[...]

Scenario Outline: Monthly interestGiven an account with balance €1000And the annual interest rate is <rate>%And the start date is 01.01.2012When 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

Page 36: CodeCamp Iasi 10 march 2012 - Cucumber

... and more

sâmbătă, 10 martie 12

Page 37: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 38: CodeCamp Iasi 10 march 2012 - Cucumber

Dan Northhttp://dannorth.net

Aslak Hellesøyhttp://www.aslakhellesoy.com

sâmbătă, 10 martie 12

Page 39: CodeCamp Iasi 10 march 2012 - Cucumber

JUnit

Cucumber

sâmbătă, 10 martie 12

Page 40: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 41: CodeCamp Iasi 10 march 2012 - Cucumber

http://cukes.info - Official project page

sâmbătă, 10 martie 12

Page 42: CodeCamp Iasi 10 march 2012 - Cucumber

One more thing

sâmbătă, 10 martie 12

Page 43: CodeCamp Iasi 10 march 2012 - Cucumber

# language: roFuncționalitate: Depozit bancarPentru a atrage fonduriÎn calitate de bancherDoresc 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 €10

sâmbătă, 10 martie 12

Page 44: CodeCamp Iasi 10 march 2012 - Cucumber

sâmbătă, 10 martie 12

Page 45: CodeCamp Iasi 10 march 2012 - Cucumber

A tool for:

* Acceptance testing

* Requirements description

* COMMUNICATION

sâmbătă, 10 martie 12

Page 46: CodeCamp Iasi 10 march 2012 - Cucumber

Questions, please

sâmbătă, 10 martie 12

Page 47: CodeCamp Iasi 10 march 2012 - Cucumber

Thank you!And please don’t forget the evaluation form :-)

sâmbătă, 10 martie 12