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
TDDとVimと
Search
Yuta Totz
October 23, 2015
Programming
1
480
TDDとVimと
RailsまわりのTDDと、Vimについて。
Yuta Totz
October 23, 2015
Tweet
Share
More Decks by Yuta Totz
See All by Yuta Totz
ウガンダでXcodeをアップデートする方法
totzyuta
0
110
Working with UNIX Process 6/7 Chapter
totzyuta
1
60
珈琲と僕
totzyuta
0
89
読んで理解するActiveRecordの設計とActiveSupport::Concern
totzyuta
4
1.5k
モテる!筋肉コンパイラ自作入門 - 草食男子からの卒業
totzyuta
0
420
Git/GitHub入門-GitHubでたのしいチーム開発
totzyuta
0
290
Vimmer幼稚園
totzyuta
2
110
たのしいたーみなる
totzyuta
0
40
Other Decks in Programming
See All in Programming
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
140
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
790
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
4
580
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
490
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
Kaigi on Railsに初参加したら、その日にLT登壇が決定した件について
tama50505
0
100
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
280
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
Haze - Real time background blurring
chrisbanes
1
510
42 best practices for Symfony, a decade later
tucksaun
1
180
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Thoughts on Productivity
jonyablonski
67
4.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
How STYLIGHT went responsive
nonsquared
95
5.2k
Optimising Largest Contentful Paint
csswizardry
33
3k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
A designer walks into a library…
pauljervisheath
204
24k
Transcript
TDD ͱ Vim ͱ Red-Green-Refactoring Cycle with Vim
Resume • Introduction • What is “test”? • TDD on
Red-Green-Refactor Cycle • TDD by Vim • Demo • Conclusion • Links and Books
ࣗݾհ
ͱͭ ށ௩ ༎ଠ (@totzyuta) OneBox Inc. ίʔώʔ ݉ WebΤϯδχΞ
ςετɺॻ͍ͯ·͔͢ʁ
What is “test”?
What is test? • ΞϓϦέʔγϣϯ͕ਖ਼͘͠ಈ͘͜ͱΛอূ͢ ΔͨΊͷΞϓϦέʔγϣϯͰͳ͍ίʔυ • ୯ମςετɺػೳςετɺ૯߹ςετ • (ݺͼํͷఆ͍ٛ͋·͍)
• UnitςετͱFeatureςετ
Categories of Tests • Unitςετ • ૄ݁߹తͳUnit͝ͱͷ࠴Λอূ͢Δ • associationͷਖ਼͠͞ͷ୲อ •
Featureςετ • Unitؒͷ݁߹ • => ػೳશମͱͯ͠ͷಈ͖ͷਖ਼͠͞Λอূ͢Δ • Model, Controller, ViewΛ۲͠Ͱ͖Δʂ
Testing Frameworks • Minitest • Railsඪ४ (DHHਞ) • ຊͰ࠷ۙͪΐͬͱ͏ਓ૿͖͑ͯͨ •
RSpec • ͳΜ͔Ή͠Ζඪ४Έ͍ͨʹͳͬͯͨ • ൈຊతͳ༷มߋ͕ಘҙ
3 Principles of Writing Tests • ςετ৴པͰ͖ΔͷͰ͋Δ͜ͱ • ςετ؆୯ʹॻ͚Δ͜ͱ •
ςετ؆୯ʹཧղͰ͖Δ͜ͱ ref. Everyday Rails - RSpecʹΑΔRailsςετೖ - Aaron Sumner, Junichi Ito, AKIMOTO Toshiharu, ৼߐ ڕ
TDD on Red-Green- Refactor Cycle
“TDD is dead.” — David Heinemeier Hansson
What is TDD? • ʮϏδωεϓϩάϥϜΛॻ͘લʹɺςετίʔ υΛॻ͘͜ͱʯ • ςετ͕༷ॻʹͳΔ (!!) •
Red-Green-Refactor Cycle
Flow of TDD on Red-Green-Refactor Cycle 1. ςετͰઃܭॻΛॻ͘ (RED) 2.
࠷͔ͭ࠷؆୯ʹςετΛ௨͢ίʔυΛॻ͘ (GREEN) • ͍ͭ͜ςετίʔυͷςετ 3. ϦϑΝΫλϦϯά (Refactor) • ͜Ε͕ຊؾͷ࣮ • “ϦϑΝΫλϦϯά”ͬͯͭͱͪΐͬͱҧ͏ • Red͕ΘΔ͍ɺGreen͕Α͍Ͱͳ͍ʂ ref. cookpad 2015 summer internship TDD by Yoshiori SHOJI
TDD - ϝϦοτᶃ • ςετίʔυΛઌʹॻ͘͜ͱʹΑͬͯɺࣗ ͕࡞Δ͖ϓϩάϥϜ͕໌֬Խ͢Δɻ • ࣄલʹ࡞͢ΔϓϩάϥϜΠϝʔδ͕ੜ·Ε ΔͨΊ༷ᴥᴪʹؾͮ͘ػձ͕ૣΊʹ๚Ε Δɻ
TDD - ϝϦοτᶅ • ςετίʔυ͕ඞͣશͯ࡞͞ΕΔ • Ϟνϕʔγϣϯ • ෆ҆Λ๊͑ͨ··ͷ։ൃ͞Α͏ͳΒ
Vim
VimͰRailsͳϓϥάΠϯ • jodosha/vim-greenbar • jodosha/vim-devnotes • dbext.vim • tpope/rails.vim •
The-NERD-tree
VimͰRailsͳϓϥάΠϯ • bronson/vim-trailing-whitespace • tpope/vim-endwise • vim-scripts/AnsiEsc.vim
ුؾ૬ख
Demo
Demo $ rails new coedotask $ rails g scaffold Task
name:string time:integer • λεΫཧΞϓϦέʔγϣϯ - coedotask • ͜Εʹ Task.calc_total_time ΛՃ͠·͢ʂ
Flow of TDD on Red-Green-Refactor Cycle 1. ςετͰઃܭॻΛॻ͘ (RED) 2.
࠷͔ͭ࠷؆୯ʹςετΛ௨͢ίʔυΛॻ͘ (GREEN) • ͍ͭ͜ςετίʔυͷςετ 3. ϦϑΝΫλϦϯά (Refactor) • ͜Ε͕ຊؾͷ࣮ • “ϦϑΝΫλϦϯά”ͬͯͭͱͪΐͬͱҧ͏ • Red͕ΘΔ͍ɺGreen͕Α͍Ͱͳ͍ʂ ref. cookpad 2015 summer internship TDD by Yoshiori SHOJI
Conclusion • TDD։ൃऀΛͤʹͯ͘͠ΕΔ (?) • “TDD is dead” ͔͔Βͳ͍͚ͲͻͱΓͻͱ Γͷ࣮ફ͕Web։ൃʹ͓͚ΔςεςΟϯάͷ
ະདྷΛܾΊ͍ͯ͘ • ʹͳͬͯͨͷ͍͠
͋Δͷ͜ͱ
None
*ŋʄƅŋ*:.Ň..Ň.:*ŋ'( ƅ˜ƅ*)'ŋ*:.Ň. .Ň.:*ŋʄƅŋ*
None
*ŋʄƅŋ*:.Ň..Ň.:*ŋ'( ƅ˜ƅ*)'ŋ*:.Ň. .Ň.:*ŋʄƅŋ*
ॻ੶ • Everyday Rails Testing with RSpecTDD • Aaron Sumner
ࢀߟ • BDDʹ͍ͭͯࣗͳΓʹ·ͱΊͯΈͨ • TDD is dead. Long live testing.
• Effective TDD With Ruby: Time & Flow
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ