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.7k
個人開発のやっていき方
r7kamura
94
23k
amakanにおける書籍のシリーズ判定方法について 2016-08-21
r7kamura
10
6.1k
Tenkaichi Bot Butoukai
r7kamura
11
5.2k
Paging in API
r7kamura
3
8.7k
Chanko Hacking Guide
r7kamura
5
1.3k
Making things with something small
r7kamura
1
490
Hidden
r7kamura
0
96
Butsukari Geiko
r7kamura
10
37k
Other Decks in Programming
See All in Programming
Strands Agents で実現する名刺解析アーキテクチャ
omiya0555
1
120
あまり知られていない MCP 仕様たち / MCP specifications that aren’t widely known
ktr_0731
0
240
202507_ADKで始めるエージェント開発の基本 〜デモを通じて紹介〜(奥田りさ)The Basics of Agent Development with ADK — A Demo-Focused Introduction
risatube
PRO
6
1.4k
iOS開発スターターキットの作り方
akidon0000
0
240
대규모 트래픽을 처리하는 프론트 개발자의 전략
maryang
0
120
DataformでPythonする / dataform-de-python
snhryt
0
160
Go製CLIツールをnpmで配布するには
syumai
2
1.2k
可変性を制する設計: 構造と振る舞いから考える概念モデリングとその実装
a_suenami
10
1.7k
リッチエディターを安全に開発・運用するために
unachang113
1
380
LLMは麻雀を知らなすぎるから俺が教育してやる
po3rin
3
2.1k
パスタの技術
yusukebe
1
260
ライブ配信サービスの インフラのジレンマ -マルチクラウドに至ったワケ-
mirrativ
1
140
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.9k
The Pragmatic Product Professional
lauravandoore
36
6.8k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Code Reviewing Like a Champion
maltzj
524
40k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Fireside Chat
paigeccino
38
3.6k
Gamification - CAS2011
davidbonilla
81
5.4k
Making Projects Easy
brettharned
117
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