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.8k
Test on Rails ✘╹◡╹✘
r7kamura
September 19, 2012
Tweet
Share
More Decks by r7kamura
See All by r7kamura
Railsアップグレード百景
r7kamura
11
6.5k
個人開発のやっていき方
r7kamura
94
23k
amakanにおける書籍のシリーズ判定方法について 2016-08-21
r7kamura
10
6k
Tenkaichi Bot Butoukai
r7kamura
11
5.1k
Paging in API
r7kamura
3
8.5k
Chanko Hacking Guide
r7kamura
5
1.2k
Making things with something small
r7kamura
1
450
Hidden
r7kamura
0
73
Butsukari Geiko
r7kamura
10
36k
Other Decks in Programming
See All in Programming
Kotlinの好きなところ
kobaken0029
0
220
Nuxtベースの「WXT」でChrome拡張を作成する | Vue Fes 2024 ランチセッション
moshi1121
1
290
今日で分かる!カスタムコップの作り方
krpk1900
2
360
OpenTelemetryでRailsのパフォーマンス分析を始めてみよう(KoR2024)
ymtdzzz
3
1k
Dev ContainersとGitHub Codespacesの素敵な関係
ymd65536
1
120
生成 AI を活用した toitta 切片分類機能の裏側 / Inside toitta's AI-Based Factoid Clustering
pokutuna
0
530
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
120
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
0
210
JaSST 24 九州:ワークショップ(は除く)実践!マインドマップを活用したソフトウェアテスト+活用事例
satohiroyuki
0
170
Vue3の一歩踏み込んだパフォーマンスチューニング2024
hal_spidernight
3
2.9k
ピクシブ百科事典のWebフロントエンドパフォーマンス改善
higara
0
230
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
440
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2k
Into the Great Unknown - MozCon
thekraken
31
1.5k
How to train your dragon (web standard)
notwaldorf
88
5.6k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
27
1.9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Music & Morning Musume
bryan
46
6.1k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.8k
[RailsConf 2023] Rails as a piece of cake
palkan
51
4.8k
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.4k
The Pragmatic Product Professional
lauravandoore
31
6.3k
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