1
BDD x cucumber Sam Huang 2015/03/26Allen Huang @ CCAgile
2
黃相文 Sam Huang2nd year of Master in
NTUT
3
前言
黃柏棋 Allen Huang2nd year of Master in
NTUT
4
TDD
BDD
BDD vs TDD
5
What is BDD ?
Behavior-driven Development
行為驅動開發
ビヘイビア駆動開発
행위 주도 개발
การพั�ฒนาพัฤติกรรมการขั�บเคลื่��อน
6
Behavior-driven Development? User’s behavior
是一種敏捷開發的技術,它鼓勵軟體中的開發者 , QA 與非技術人員或商業參與者之間的協作。 From Wikipedia
7http://projectcartoon.com/
Coding / UTAT
8
PO QA Developers
User Story
Traditional Software Development
Software
X
Coding / UT
9
PO QA Developers
User Story
BDD
Software
Feature Steps
AT
10
User Story Acceptance Test
Feature Steps
PO QA
11http://blog.andolasoft.com/2014/06/rails-things-you-must-know-about-tdd-and-bdd.html
Cons
1. 非技術人員與技術人員間更容易溝通
2. 技術人員可以更專注在程式上
3. 規格就是程式碼
4. 降低文件同步的成本
5. 完整了開發流程
12
Feature Steps透過關鍵字來描述功能,將
User Story 轉成可執行的程式
將 Feature 內的流程對應到
使用者操作的步驟
Ruby
gem install cucumber
13
14https://cukes.info/blog/2015/03/24/single-source-of-truth
How to use cucumber?
15
Given ThenWhen
定義在這個流程中的前提條件
定義在什麼情況下會發生這個流程
定義在這個流程結束後,你想得到什麼樣
的結果
16
Feature : Login
In order to use system
As a user
I can type my user name and password on login page
Scenario : Login successfully
Given I am on the system login page
When type my user name and password
Then login system, and see main page
Feature File - Eng
功能:登入 為了使用系統 身為使用者 我可以在登入頁面輸入我的帳號及密碼來登入
場景:成功登入 假如 我在系統的登入頁面 當 我輸入我的帳號及密碼 那麼 我可以登入系統,且看到系統的主頁面
Feature File – 中文
Given(/^I am on the system login page$/) do
bar bar bar …
end
When(/^type my user name and password$/) do
bar bar bar …
end
Then(/^login system, and see main page$/) do
bar bar bar …
end
Step File
Numerical Input Steps
Feature
21
Quotation marks Input
Steps
Feature
22
Table Input
Steps
Feature
23
小小計算機
25
You can clone this app from Github.https://github.com/imidya/WebCalculator
Algorithm (×, ÷)
+ 4 × 3 - 9 ÷ 35
27
Algorithm (×, ÷)
4 × 3 - 9 ÷ 3
5
+
28
Algorithm (×, ÷)
× 3 - 9 ÷ 3
5+
4
29
Algorithm (×, ÷)
- 9 ÷ 3
5+4
× 3
12
30
Algorithm (×, ÷)
9 ÷ 3
5+12
-
31
Algorithm (×, ÷)
9
5+12-
3÷
32
Algorithm (×, ÷)
9
5+12-
3÷
3
33
Algorithm (+, -)
35 + 12 -
34
Algorithm (+, -)
3
5
+ 12 -
17
35
Algorithm (+, -)
3
17
-
14
36