Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 1
Bridging the gap between
Business and IT using
Cucumber
黃俊喬 (Woody Huang)
December 2015
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 2
About Woody
• 黃俊喬 woody.huang@kosmossystems.com
• Work @ HTC before
• Work @ KOSMOS Banking
• Github: https://goo.gl/kkBzre
• Codenvy: https://goo.gl/ZuZsmo
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 3
Agenda
• The problems of common software development process
• What BDD (Behavior-driven development) can help
• How to leverage Cucumber
• Anti-Patterns
• More Cucumber
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 4
Defects in Software
• Implementation defects => bugs
 Automated test
 Code review
 Continuous integration
 Code inspection tools
• Requirement defects => missing requirement, misunderstanding
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 5
Misunderstanding
 My wife said: "Please go to the store and buy a carton of milk and if they have eggs,
get six."
+
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 6
Misunderstanding
 My wife said: "Please go to the store and buy a carton of milk and if they have eggs,
get six."
 I came back with 6 cartons of milk
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 7
Misunderstanding
 My wife said: "Please go to the store and buy a carton of milk and if they have eggs,
get six."
 I came back with 6 cartons of milk
 She said, "why in the hell did you buy six cartons of milk“
 "They had eggs"
+
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 8
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 9
We have…
• Automated test
• TDD
• Release early, release often
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 10
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 11
一份文件不夠,
你有寫二份嗎?
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 12
Test
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 13
Unit Test
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 14
TDD
Unit Test
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 15
BDD
TDD
Unit Test
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 16
Business Goal
Requirement
Documents
System Under Test
System &
Working Automated
Unit Tests
Business analyst talks with business
owner about what he needs
Business analyst writes
requirement documents
Developer translates the
requirement into software
Tester translates the
requirement into test cases
Common Practice
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 17
Business Goal
Requirement
Documents
System Under Test
System &
Working Automated
Unit Tests
Business analyst talks with business
owner about what he needs
Business analyst writes
requirement documents
Developer translates the
requirement into software
Tester translates the
requirement into test cases
Common Practice
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 18
Business Goal
Features and
Scenarios as
Requirement
Documents
System Under Test
System &
Working Automated
Acceptance Tests
Business analyst talks with business
owner about what he needs
Business analyst writes feature document.
Business analyst, developer and tester discuss the
feature together and write scenarios in natural
language as agreement on “done”
Scenarios drive the design, implementation and act
as automated test
Tester use the scenarios
as their test cases
BDD
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 19
Business Goal
Features and
Scenarios as
Requirement
Documents
System Under Test
System &
Working Automated
Acceptance Tests
Business analyst talks with business
owner about what he needs
Business analyst writes feature document.
Business analyst, developer and tester discuss the
feature together and write scenarios in natural
language as agreement on “done”
Scenarios drive the design, implementation and act
as automated test
Tester use the scenarios
as their test cases
BDD
Shared
Understanding
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 20
Business Goal
Features and
Scenarios as
Requirement
Documents
System Under Test
System &
Working Automated
Acceptance Tests
Business analyst talks with business
owner about what he needs
Business analyst writes feature document.
Business analyst, developer and tester discuss the
feature together and write down scenarios in natural
language as agreement on “done”
Scenarios drive the design, implementation and act
as automated test
Tester use the scenarios
as their test cases
BDD
Shared
Understanding
Specification
by Examples
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 21
Login feature
Feature
Feature: Login
As a user
I want to log in to the website
so that I can access to the content
User Story
Feature: Narrative
As a [role]
I want [desire/goal]
so that [benefit]
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 22
Login feature
Feature
Feature: Login
As a user
I want to log in to the website
so that I can access to the content
Scenarios
Scenario: Title
Given [context/pre-condition]
And [more context] …
When [event]
And [more event] …
Then [outcome]
And [more outcome] …
User Story Acceptance Criteria
Business analyst, developer and tester
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 23
Login feature
Scenario: valid credentials
Given I registered an account on the website with username "tim.duncan" and password "P@ssw0rd”
When I provide the username "tim.duncan"
And correct password "P@ssw0rd”
And submit my request
Then I should be successfully logged in
Scenario: invalid credentials
Given I registered an account on the website with username "tim.duncan" and password "P@ssw0rd”
When I provide the username "tim.duncan"
And wrong password "wrongPwd"
And submit my request
Then I should not be logged in
More …..
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 24
Login feature
Scenario Step Definitions
Scenario: valid credentials
Given I registered an account on the website with
username "tim.duncan" and password "P@ssw0rd”
When I provide the username "tim.duncan"
And correct password "P@ssw0rd”
And submit my request
Then I should be successfully logged in
…..
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 25
Loginfeature
Step
Definitions
Automated
Test Code
Test
Implemen
t
Refactor
Test
Implemen
t
Refactor
……
System &
Working
Automated
Acceptance Tests
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 26
Rhyme of BDD
Failing
Acceptance
Test
Failing
Unit Test
Test Pass
Refactor
Acceptance
Pass
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 27
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 28
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 29
ANTI-PATTERNS
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 30
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 31
Share understanding
 My wife said: "Please go to the store and buy a carton of milk and if they have eggs,
get six."
+
Scenario: Buy milk and eggs
Given My husband buys a carton of milk
When he finds there are eggs
Then he buys a carton of milk and six eggs
+
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 32
Programming languageNatural language (English/中文)
Feature Scenarios Step Definitions
BDD using Cucumber
What How Automated
Test Code
System &
Working
Automated
Acceptance Tests
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 33
So What is BDD
• Active stakeholder participation
• Specification by examples (scenario)
• Ubiquitous language Domain specific language (DSL) using natural language
• Building the right software (outside-in)
• Living specification
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 34
Anti-Patterns
• Business analyst writes the scenarios without discussing with tester and developer
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 35
Anti-Patterns
• Business analyst writes the scenarios without discussing with tester and developer
• Tester writes the scenarios at the end of development cycle
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 36
Anti-Patterns
• Business analyst writes the scenarios without discussing with tester and developer
• Tester writes the scenarios at the end of development
• The ”Three Amigos” sessions don’t result in usable scenarios, so the developer
invents them afterwards
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 37
Anti-Patterns
• Business analyst writes the scenarios without discussing with tester and developer
• Tester writes the scenarios at the end of development cycle
• The ”Three Amigos” sessions fail to result in usable scenarios, so the developer
invents them afterwards
• The scenarios are too UI-centric or detail-focused , and fail to express the core
business value.
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 38
INTRODUCE CUCUMBER TO YOUR
PROJECT
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 39
QUESTIONS & DISCUSSION
Produced by: 黃俊喬 (Woody Huang)
Date: December 2015 Slide 40
WE ARE HIRING!

Bridging the gap between business and it using cucumber

  • 1.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 1 Bridging the gap between Business and IT using Cucumber 黃俊喬 (Woody Huang) December 2015
  • 2.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 2 About Woody • 黃俊喬 woody.huang@kosmossystems.com • Work @ HTC before • Work @ KOSMOS Banking • Github: https://goo.gl/kkBzre • Codenvy: https://goo.gl/ZuZsmo
  • 3.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 3 Agenda • The problems of common software development process • What BDD (Behavior-driven development) can help • How to leverage Cucumber • Anti-Patterns • More Cucumber
  • 4.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 4 Defects in Software • Implementation defects => bugs  Automated test  Code review  Continuous integration  Code inspection tools • Requirement defects => missing requirement, misunderstanding
  • 5.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 5 Misunderstanding  My wife said: "Please go to the store and buy a carton of milk and if they have eggs, get six." +
  • 6.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 6 Misunderstanding  My wife said: "Please go to the store and buy a carton of milk and if they have eggs, get six."  I came back with 6 cartons of milk
  • 7.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 7 Misunderstanding  My wife said: "Please go to the store and buy a carton of milk and if they have eggs, get six."  I came back with 6 cartons of milk  She said, "why in the hell did you buy six cartons of milk“  "They had eggs" +
  • 8.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 8
  • 9.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 9 We have… • Automated test • TDD • Release early, release often
  • 10.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 10
  • 11.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 11 一份文件不夠, 你有寫二份嗎?
  • 12.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 12 Test
  • 13.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 13 Unit Test
  • 14.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 14 TDD Unit Test
  • 15.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 15 BDD TDD Unit Test
  • 16.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 16 Business Goal Requirement Documents System Under Test System & Working Automated Unit Tests Business analyst talks with business owner about what he needs Business analyst writes requirement documents Developer translates the requirement into software Tester translates the requirement into test cases Common Practice
  • 17.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 17 Business Goal Requirement Documents System Under Test System & Working Automated Unit Tests Business analyst talks with business owner about what he needs Business analyst writes requirement documents Developer translates the requirement into software Tester translates the requirement into test cases Common Practice
  • 18.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 18 Business Goal Features and Scenarios as Requirement Documents System Under Test System & Working Automated Acceptance Tests Business analyst talks with business owner about what he needs Business analyst writes feature document. Business analyst, developer and tester discuss the feature together and write scenarios in natural language as agreement on “done” Scenarios drive the design, implementation and act as automated test Tester use the scenarios as their test cases BDD
  • 19.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 19 Business Goal Features and Scenarios as Requirement Documents System Under Test System & Working Automated Acceptance Tests Business analyst talks with business owner about what he needs Business analyst writes feature document. Business analyst, developer and tester discuss the feature together and write scenarios in natural language as agreement on “done” Scenarios drive the design, implementation and act as automated test Tester use the scenarios as their test cases BDD Shared Understanding
  • 20.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 20 Business Goal Features and Scenarios as Requirement Documents System Under Test System & Working Automated Acceptance Tests Business analyst talks with business owner about what he needs Business analyst writes feature document. Business analyst, developer and tester discuss the feature together and write down scenarios in natural language as agreement on “done” Scenarios drive the design, implementation and act as automated test Tester use the scenarios as their test cases BDD Shared Understanding Specification by Examples
  • 21.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 21 Login feature Feature Feature: Login As a user I want to log in to the website so that I can access to the content User Story Feature: Narrative As a [role] I want [desire/goal] so that [benefit]
  • 22.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 22 Login feature Feature Feature: Login As a user I want to log in to the website so that I can access to the content Scenarios Scenario: Title Given [context/pre-condition] And [more context] … When [event] And [more event] … Then [outcome] And [more outcome] … User Story Acceptance Criteria Business analyst, developer and tester
  • 23.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 23 Login feature Scenario: valid credentials Given I registered an account on the website with username "tim.duncan" and password "P@ssw0rd” When I provide the username "tim.duncan" And correct password "P@ssw0rd” And submit my request Then I should be successfully logged in Scenario: invalid credentials Given I registered an account on the website with username "tim.duncan" and password "P@ssw0rd” When I provide the username "tim.duncan" And wrong password "wrongPwd" And submit my request Then I should not be logged in More …..
  • 24.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 24 Login feature Scenario Step Definitions Scenario: valid credentials Given I registered an account on the website with username "tim.duncan" and password "P@ssw0rd” When I provide the username "tim.duncan" And correct password "P@ssw0rd” And submit my request Then I should be successfully logged in …..
  • 25.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 25 Loginfeature Step Definitions Automated Test Code Test Implemen t Refactor Test Implemen t Refactor …… System & Working Automated Acceptance Tests
  • 26.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 26 Rhyme of BDD Failing Acceptance Test Failing Unit Test Test Pass Refactor Acceptance Pass
  • 27.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 27
  • 28.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 28
  • 29.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 29 ANTI-PATTERNS
  • 30.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 30
  • 31.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 31 Share understanding  My wife said: "Please go to the store and buy a carton of milk and if they have eggs, get six." + Scenario: Buy milk and eggs Given My husband buys a carton of milk When he finds there are eggs Then he buys a carton of milk and six eggs +
  • 32.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 32 Programming languageNatural language (English/中文) Feature Scenarios Step Definitions BDD using Cucumber What How Automated Test Code System & Working Automated Acceptance Tests
  • 33.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 33 So What is BDD • Active stakeholder participation • Specification by examples (scenario) • Ubiquitous language Domain specific language (DSL) using natural language • Building the right software (outside-in) • Living specification
  • 34.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 34 Anti-Patterns • Business analyst writes the scenarios without discussing with tester and developer
  • 35.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 35 Anti-Patterns • Business analyst writes the scenarios without discussing with tester and developer • Tester writes the scenarios at the end of development cycle
  • 36.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 36 Anti-Patterns • Business analyst writes the scenarios without discussing with tester and developer • Tester writes the scenarios at the end of development • The ”Three Amigos” sessions don’t result in usable scenarios, so the developer invents them afterwards
  • 37.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 37 Anti-Patterns • Business analyst writes the scenarios without discussing with tester and developer • Tester writes the scenarios at the end of development cycle • The ”Three Amigos” sessions fail to result in usable scenarios, so the developer invents them afterwards • The scenarios are too UI-centric or detail-focused , and fail to express the core business value.
  • 38.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 38 INTRODUCE CUCUMBER TO YOUR PROJECT
  • 39.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 39 QUESTIONS & DISCUSSION
  • 40.
    Produced by: 黃俊喬(Woody Huang) Date: December 2015 Slide 40 WE ARE HIRING!