Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Test with :)
Search
aquajach
October 26, 2013
Technology
140
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Test with :)
The slides for Rubyconf China 2013 with animation off
aquajach
October 26, 2013
More Decks by aquajach
See All by aquajach
Separate the data logic from your application
aquajach
0
86
Grow from Small Simple Steps
aquajach
0
520
Other Decks in Technology
See All in Technology
LLM機能を自作して分かるSnowflake Cortex AIの強み
nayuts
0
110
AWS DevOps Agent スキルをつかいこなそう / Master AWS DevOps Agent Skills
kinunori
2
650
Oracle Cloud Infrastructure(OCI):Onboarding Session(はじめてのOCI/Oracle Supportご利⽤ガイド)
oracle4engineer
PRO
3
21k
TiDBファミリーにDWHが新登場!! TiDB最新情報 / TiDB update 202609
yoshiakiyamasaki
0
180
行動するAIのためのオントロジー | DevRev — Encraft #26.pdf
dvrv_tknrszk
2
660
HacobuにおけるFDEとは/登壇資料(戸井田 裕貴)
hacobu
PRO
1
690
「とりあえず動く」の先へ。 AI時代のチーム開発と内部設計/2026-slsdays
slsops
0
100
DORA_Metrics.pdf
wagnerfusca
1
140
HolmesGPTで始めるSREエージェント入門!プラットフォームの障害調査はAIにお任せ 〜
sanghyuk
0
250
The kernel report
ennael
PRO
1
180
大阪オフィスに Unitree Go2 がやってきたので Physical AI やってみた
dafujii
0
210
カンファレンスに参加した後の浮遊感とセルフケア
pauli
0
290
Featured
See All Featured
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
450
Fireside Chat
paigeccino
43
4k
New Earth Scene 8
popppiees
4
2.6k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
Paper Plane
katiecoart
PRO
4
53k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
350
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
The Cult of Friendly URLs
andyhume
79
7k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
270
Building Applications with DynamoDB
mza
96
7.2k
Transcript
test with :) chen songyong
about me
about me • Remote worker! • Worked in start-ups, web
consultancies , banks and digital agencies! • @aquajach in Twitter & Github
test in old days
do you ❤️ write test? do you write test?
Q & A
why you test • Forget to go for test first
technical debt "we have not found anything to ease the
transition from 'hairball of code with no unit tests' to 'unit-testable code'."
trust your mind code
my practice integration test controller test model / lib test
my practice Test Implementation “Pay” button works controller deals with
pay request model/lib makes the transaction views controller model/lib pass pass pass
why you test • Forget to write test first! •
Too much extra work
is it true? Writing test adds 15-35% development time in
return for a 40-90% reduction in defect density on otherwise like-for-like projects. - A paper in ESE •YES
is it true? •No! v.s. test in rails console
why you test • Forget to write test first! •
Extra work! • Maintenance is painful
it 'Sign Up should have title' do! visit '/tc/'! page.find('div#sign-up-modal').should
have_css(‘#modalHeader.h5-sign-up-header’, :text => “Apple Now”) ! end
why you test • Forget to write test first! •
Extra work! • Maintenance is painful! • Running test takes longer and longer
easiest way to go • CPU! ! • Data storage!
! • Memory
test suite example • ruby 2.0.0 / rails 3.2.13 /
rspec-rails ~>2.0 / PostgreSQL /Factory Girl / Database cleaner! • 370+ mixed with unit test, integration test (w/ capybara inc. JavaScript)! • No remote request (w/ VCR)
Tool / Framework • spork! • zeus! • spring! •
Parallel test! • Guard! • … … Ryan Bates’ Railscasts SKIP
rspec v.s. rake spec Update: run via bin/rspec
database clean strategy • :transaction! • simply rollback - fastest!
• Failed at:! • multiple connections! • integration test
database clean strategy • :truncation! • TRUNCATE table! • remove
all records! • VACUUM table! • index! • Failed at:! • concurrent access to a table
database clean strategy • :deletion! • DELETE from table! •
scan the table! • less predictable! • Bad at:! • Large tables
Deletion Truncation
database Clean strategy
refactor gemfile • stop loading gems not used in the
code! • e.g. gem ‘unicorn’, require: false! • specify dependencies for test environment! • ‘jquery-rails’, ‘will_paginate’, ‘exception_notification’
defer garbage collection
Original + rspec command + DB clean strategy + refactor
Gemfile + delay garbage collection 0 65 130 195 260
factory v.s. fixture • Flexibility! ! • Callbacks & validations!
! • Speed
! best practice • create(:user) v.s. build(:user) v.s. build_stubbed(:user)! •
require ‘spec_helper’ v.s. require ‘lib_class.rb’! • mock/stub or not to mock/stub! • let v.s. let! v.s. before block
not about speed but... • Selective testing! • slow! •
focus! • Fail immediately --fail-fast! • Display message immediately! -- format Fuubar! • rspec -p spec
(real) Q & A