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
Test on Rails ✘╹◡╹✘
Search
r7kamura
September 19, 2012
Programming
10
3.9k
Test on Rails ✘╹◡╹✘
r7kamura
September 19, 2012
Tweet
Share
More Decks by r7kamura
See All by r7kamura
Railsアップグレード百景
r7kamura
11
6.6k
個人開発のやっていき方
r7kamura
94
23k
amakanにおける書籍のシリーズ判定方法について 2016-08-21
r7kamura
10
6.1k
Tenkaichi Bot Butoukai
r7kamura
11
5.2k
Paging in API
r7kamura
3
8.6k
Chanko Hacking Guide
r7kamura
5
1.3k
Making things with something small
r7kamura
1
470
Hidden
r7kamura
0
87
Butsukari Geiko
r7kamura
10
36k
Other Decks in Programming
See All in Programming
Amazon CloudWatchの地味だけど強力な機能紹介!
itotsum
0
170
複雑なフォームの jotai 設計 / Designing jotai(state) for Complex Forms #layerx_frontend
izumin5210
4
1k
The Evolution of the CRuby Build System
kateinoigakukun
0
710
状態と共に暮らす:ステートフルへの挑戦
ypresto
1
630
プロフェッショナルとしての成長「問題の深掘り」が導く真のスキルアップ / issue-analysis-and-skill-up
minodriven
7
1.2k
Vibe Codingをせずに Clineを使っている
watany
17
6.3k
リストビュー画面UX改善の振り返り
splcywolf
0
140
Making TCPSocket.new "Happy"!
coe401_
1
1.5k
Fiber Scheduler vs. General-Purpose Parallel Client
hayaokimura
1
100
Rollupのビルド時間高速化によるプレビュー表示速度改善とバンドラとASTを駆使したプロダクト開発の難しさ
plaidtech
PRO
1
170
Enterprise Web App. Development (1): Build Tool Training Ver. 5
knakagawa
1
120
PHPバージョンアップから始めるOSSコントリビュート / how2oss-contribute
dmnlk
1
1.1k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
693
190k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
104
19k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Adopting Sorbet at Scale
ufuk
76
9.3k
Faster Mobile Websites
deanohume
306
31k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
135
33k
Statistics for Hackers
jakevdp
798
220k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.5k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
119
51k
Site-Speed That Sticks
csswizardry
5
500
Transcript
Test on Rails based on “Rails Test Prescriptions” by Noel
Rappin Ryo Nakamura (@r7kamura) ✘ ╹◡╹ ✘
1. Why test? 2. Unit 3. Model 4. Functional 5.
View 6. Integration
Why test?
* to speed up validation * to design architectures *
to assure its quality ... Why test?
to speed up validation automating test * open browser... *
type the URL “h..tt..p://...” * check the contents...
to design architecture * write clean and independent code (test
behaves like a third-party code) * think the correct behavior of code (this would be an example of test)
to assure its quality * prevent code from enbugging *
maybe forced to write test ... ;(
For more details why you... Please ask Mohicans around you
Unit Test
Forms of writing unit test - ✘╹◡╹ ✘ http://r7kamura.hatenablog.com/ entry/2012/09/19/113239
Unit Test
Model Test
Unit Test of Model. It's easy to write Model Test.
"Skinny Controller, Fat Model" Model Test
Functional Test
Functional tests Verify the system satisfies requested features of user.
In Rails, it tests Controller & View by 1 request
Targets 1. normal 2. invalid 3. security
1. normal A normal request should pass expected data to
the view. @foo, sessions, cookies, flash
2. invalid An invalid request should be handled properly. redirect_to
:root
3. security User’s and system’s security should be protected. get(others_entry_path).
should_not be_success
Non targets * many redirections * user interaction * HTTP
methods (in Rails)
View Test
View Test Verify: * logic * structure (semantic mean) Used
in Controller & Integration Test on Rails
Good targets * logic in a view (necessary evil...;) *
security problem * way to render structures
Bad targets * text in HTML tag * look and
feel verify only “semantic meanings”
Integration Test
Integration Test verify the interactions(I/F) of multiple components Acceptance test
might see to this. Capybara, Cucumber, ...
When to use Integration Test? To validate the interactions of
the modules that are well-tested.
Good targets * interactions in multiple steps * dependency with
prev state * legacy code (black-box) * with JavaScript
Bad targets * only 1 request * only for view
testing
1. Why test? 2. Unit 3. Model 4. Functional 5.
View 6. Integration
thanks ✘ ╹◡╹ ✘ @r7kamura