Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
JavaScript UnitTest PIXNET
Search
CypressKuo
July 21, 2016
Technology
0
150
JavaScript UnitTest PIXNET
JavaScript UnitTest
CypressKuo
July 21, 2016
Tweet
Share
More Decks by CypressKuo
See All by CypressKuo
Deep-copying.pdf
cypresskuo
0
16
CSS_for_Web_Vitals.pdf
cypresskuo
0
23
談談_Code_review.pdf
cypresskuo
0
25
REST_vs_GraphQL_今夜はご注文はどっち.pdf
cypresskuo
0
5
CSS_重構.pdf
cypresskuo
0
16
跟上_JS_的腳步-ES2020.pdf
cypresskuo
0
22
Core_Web_Vitals.pdf
cypresskuo
0
31
這個時代人人都知道的敏捷開發.pdf
cypresskuo
0
37
Webassembly.pdf
cypresskuo
0
4
Other Decks in Technology
See All in Technology
AWS Observability ベストプラクティス 大紹介
o11yfes2023
0
150
Google Cloud Next '24 Recap in ZOZO AIにより変わる開発 運用/Development and operation changed by AI
gachimuchiengineer
0
190
TailwindCSSでUIライブラリを作る際のハマりどころ
shuta13
0
220
TDD - Test Driven Drupal
opdavies
0
3k
LLM評価の落とし穴~開発者目線で気をつけるポイント~
rishigami
10
3.1k
IaCからAWSに入門した初心者が CloudFormationを通して考えた「AWS操作」の使い分け
maimyyym
3
670
AI JIMY - 登壇(インストール編)
hanacchi
0
150
データ分析力を高めるSQL研修サービス『SQL Everyone』
hikarut
1
370
iThome2024 Wailing Wall of Enterprise Security
notsurprised
0
280
AWS アーキテクチャ作図入門/aws-architecture-diagram-101
ma2shita
16
6.7k
AWS Observability 関連最新アップデート
o11yfes2023
0
100
【リラン】AIの光と闇?失敗しないために知っておきたいAIリスクとその対応 ①政府の動き編
tkhresk
0
130
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
43
6.8k
No one is an island. Learnings from fostering a developers community.
thoeni
16
2.1k
Teambox: Starting and Learning
jrom
128
8.4k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
Being A Developer After 40
akosma
67
580k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
14
1.5k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
242
1.2M
Atom: Resistance is Futile
akmur
260
25k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
104
6.7k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
323
20k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
12
1.1k
Designing for Performance
lara
601
67k
Transcript
JavaScript Test -Unit Test 2+:0'6┮䷐倥揎櫧㪰%[RTGUU-WQ
Agenda Test 3W Unit Test (1 W 1 H) TDD
& BDD Test Runner & Testing Framework 2
Why 傶ԧ嘦狒䛑አ纷ୗݢ犥Ӟፗই๗螀֢ᘒ砰䌃介手 㯏梊盠蝧 仂斕犋嘦ਧ ीےᛔמ ׀᯿䯤䁎ࢴጱᵑ 3
When 樄ত樄咳獮 ਞ蕕㪔㬙ᗟ介手ૡٍ 樄咳蝱ᤈ吚Ӿ ୌ缏䛑አ纷ୗጱྯ㮆蟂犩牧᮷ᥝ砰䌃㪔䁆ᤈ介手 樄咳奾盅 ತک%XJ牧疰䌃Ӟ㮆碝ጱ介手犥嘦狒梊藮磪ᤩ狕盋 介手㪔犋ฎ㻌稞ጱ犨率牧ਙ疰猟纷ୗ蛪牧襑ᥝ瞱媲ጱ狕ྋ㪔硬臑 4
Who 㻌ز介手ҁ8QLW7HVW҂>樄咳ᘏ@ ֵአᘏᒒ介手ҁ(QGWR(QG7HVW҂>樄咳ᘏ@ 碉ݳ介手ҁ,QWHJUDWLRQ7HVW҂>樄咳ᘏ4$Ո㹓@ 涢硩介手ҁ$FFHSWDQFH7HVW҂>4$Ո㹓@ 5
Unit Test 纷ୗӾ磧ੜጱ螵蜉㻌ز 獢ୗ IXQFWLRQ 牧ฎොဩ PHWKRG 加缏ҁቘమ҂ 6
Test Driven Development ض䌃介手牧ٚ䌃纷ୗ 夺籗牏翑籗牏᯿䯤 螨عRYHUGHVLJQҁ夺籗䌃纷ୗ҂ 7RS'RZQ姘 7
Behavior Driven Development चෝ7''禊盢ጱ蝱玕粚 虏ֵአᘏ牏介手Ո㹓膏樄咳Ո㹓牧ݢ 犥አӞ䰬ጱොୗ㬵矟蝄膏ԧ薹襑穩 褔犵疥Ո扖旉矦౮纷ୗ嘨ጱ౮ 8
襑穩矟蝄物 8VHUVWRU\物>秂氂矟蝄硲Ԫጱ㻌ᤈਁ@ 蛪傶Ӟ㮆>薫ᜋ@牧౯మᥝ>粬ਧۑ胼@牧 犥>کঅ蒂@ 羬翄ᤈ傶物 *LYHQ>Ӥӥ@ :KHQ>Ԫկ@ 7KHQ>奾ຎ@DQG>ٌਙ奾ຎ@ 9
User story:[帳⼾持有⼈要領錢] ⾝為⼀個 [帳⼾持有⼈],我想要 [從 atm 領 錢],以便 [可以在銀⾏關⾨後領到錢] Given
[帳⼾餘額 100] and [有效的領款卡] and [提款機夠錢] When [帳⼾持有⼈要求提 20 元] Then [提款機應該給 20] and [帳⼾餘額 80] and [退提款卡] 10
Test Runner & Testing Framework 7HVW5XQQHU物 .DUPD 7HVWLQJ)UDPHZRUN物 8QLW7HVWMDVPLQH (QGWR(QG7HVWSURWUDFWRU
11
Demo 12 https:/ /github.com/CypressKuo/js-unit-test
租⽚系統 普通⽚ 租⾦ 100 元 / 7天、逾期 10 元 /
天 新⽚ 租⾦ 150 元 / 3天、逾期 30 元 / 天 兒童⽚ 租⾦ 40 元 / 5天、逾期 5 元 / 天 13
First Test 我租了⼀⽚普通⽚ 15 天,還⽚時需付 多少錢? 14
First Test 紅燈 綠燈 下⼀個測試 15
Second Test 我租了⼀⽚新⽚ 9 天,還⽚時需付多 少錢? 16
紅燈 回到上⼀個綠燈 (first test) 重構 綠燈 (first test) 綠燈 (second
test) 下⼀個測試 17 Second Test
More Test 我租了⼀⽚兒童⽚ 8 天和⼀⽚普通⽚ 1 天,還⽚時需付多少錢? 18
紅燈 回到上⼀個綠燈 (second test) 重構 綠燈 (second test) 綠燈 (third
test) 19 More Test
重構 紅燈 綠燈 重構 (..Loop) 20 More Test
New Requirement 新的租⽚⽅式 國⽚ 租⾦ 60 元 / 6天、逾期
10 元 / 天 租 15 天 21
Reference https:/ /karma-runner.github.io/0.13/config/configuration- file.html http:/ /www.slideshare.net/wantingj/tdd-bdd-47559903 http:/ /fbukevin.github.io/Veck/2015/01/07 /javascript-test- suit-4-test-runner-karma/
http:/ /www.codedata.com.tw/java/unit-test-the-way- changes-my-programming http:/ /www.slideshare.net/yvonne_yu/ss-51379324 http:/ /oomusou.io/phpstorm/phpstorm-tdd-refactor/ 22
Thank You!