codecamp iasi 10 march 2012 - cucumber
DESCRIPTION
TRANSCRIPT
sâmbătă, 10 martie 12
Agile Functional Specifications
Iulian Dogariu10 March 2012
sâmbătă, 10 martie 12
Customers who knowEXACTLY
what they want
sâmbătă, 10 martie 12
sâmbătă, 10 martie 12
sâmbătă, 10 martie 12
Specifications ?
sâmbătă, 10 martie 12
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
... and specification
sâmbătă, 10 martie 12
y2 = 2
An even better specification
sâmbătă, 10 martie 12
sâmbătă, 10 martie 12
SpecificationsCHANGE
and, as a result, our software changes all the time
all the time
sâmbătă, 10 martie 12
Source CodeFunctional
spec
AcceptanceTest Plan
Technical Spec
sâmbătă, 10 martie 12
Source CodeFunctional
spec
AcceptanceTest Plan
Technical Spec
sâ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
Source CodeFunctional
spec
AcceptanceTest Plan
Technical Spec
sâmbătă, 10 martie 12
Source CodeFunctional
spec
AcceptanceTest Plan
Technical Spec
sâmbătă, 10 martie 12
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
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
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
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
Source Code
Functionalspec
AcceptanceTest Plan
Technical Spec
Where Cucumber fits in
sâmbătă, 10 martie 12
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
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
sâmbătă, 10 martie 12
sâmbătă, 10 martie 12
sâmbătă, 10 martie 12
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
Cucumber Workflow
Feature file(s) Gherkin interpreter
Application codeunder test
"Steps" (acceptance test code)
sâmbătă, 10 martie 12
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
sâmbătă, 10 martie 12
sâmbătă, 10 martie 12
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
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
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
... and more
sâmbătă, 10 martie 12
sâmbătă, 10 martie 12
Dan Northhttp://dannorth.net
Aslak Hellesøyhttp://www.aslakhellesoy.com
sâmbătă, 10 martie 12
JUnit
Cucumber
sâmbătă, 10 martie 12
sâmbătă, 10 martie 12
One more thing
sâmbătă, 10 martie 12
# 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
sâmbătă, 10 martie 12
A tool for:
* Acceptance testing
* Requirements description
* COMMUNICATION
sâmbătă, 10 martie 12
Questions, please
sâmbătă, 10 martie 12
Thank you!And please don’t forget the evaluation form :-)
sâmbătă, 10 martie 12