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
490
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
120
Working with UNIX Process 6/7 Chapter
totzyuta
1
62
珈琲と僕
totzyuta
0
97
読んで理解するActiveRecordの設計とActiveSupport::Concern
totzyuta
4
1.5k
モテる!筋肉コンパイラ自作入門 - 草食男子からの卒業
totzyuta
0
420
Git/GitHub入門-GitHubでたのしいチーム開発
totzyuta
0
300
Vimmer幼稚園
totzyuta
2
110
たのしいたーみなる
totzyuta
0
41
Other Decks in Programming
See All in Programming
なぜイベント駆動が必要なのか - CQRS/ESで解く複雑系システムの課題 -
j5ik2o
14
4.7k
5分で理解する SOLID 原則 #phpcon_nagoya
shogogg
1
310
バッチを作らなきゃとなったときに考えること
irof
2
530
仕様変更に耐えるための"今の"DRY原則を考える
mkmk884
9
3.2k
コードを読んで理解するko build
bells17
1
110
Rubyで始める関数型ドメインモデリング
shogo_tksk
0
140
データベースのオペレーターであるCloudNativePGがStatefulSetを使わない理由に迫る
nnaka2992
0
230
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
55
19k
SwiftUI Viewの責務分離
elmetal
PRO
2
270
Rails 1.0 のコードで学ぶ find_by* と method_missing の仕組み / Learn how find_by_* and method_missing work in Rails 1.0 code
maimux2x
1
240
Jakarta EE meets AI
ivargrimstad
0
380
sappoRo.R #12 初心者セッション
kosugitti
0
280
Featured
See All Featured
Adopting Sorbet at Scale
ufuk
74
9.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Designing on Purpose - Digital PM Summit 2013
jponch
117
7.1k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
10
510
Code Review Best Practice
trishagee
67
18k
Designing Experiences People Love
moore
140
23k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Building Adaptive Systems
keathley
40
2.4k
Producing Creativity
orderedlist
PRO
344
40k
Why Our Code Smells
bkeepers
PRO
336
57k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.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
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ