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
100
Working with UNIX Process 6/7 Chapter
totzyuta
1
60
珈琲と僕
totzyuta
0
85
読んで理解する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
Contemporary Test Cases
maaretp
0
140
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
230
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
役立つログに取り組もう
irof
28
9.6k
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
Amazon Qを使ってIaCを触ろう!
maruto
0
410
CSC509 Lecture 11
javiergs
PRO
0
180
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
距離関数を極める! / SESSIONS 2024
gam0022
0
280
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
BBQ
matthewcrist
85
9.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
Rails Girls Zürich Keynote
gr2m
94
13k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Site-Speed That Sticks
csswizardry
0
27
Agile that works and the tools we love
rasmusluckow
327
21k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
For a Future-Friendly Web
brad_frost
175
9.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
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
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ