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 with :)
Search
aquajach
October 26, 2013
Technology
3
120
Test with :)
The slides for Rubyconf China 2013 with animation off
aquajach
October 26, 2013
Tweet
Share
More Decks by aquajach
See All by aquajach
Separate the data logic from your application
aquajach
0
79
Grow from Small Simple Steps
aquajach
0
420
Other Decks in Technology
See All in Technology
Escaping_the_Kraken_-_October_2025.pdf
mdalmijn
0
120
about #74462 go/token#FileSet
tomtwinkle
1
290
OpenAI gpt-oss ファインチューニング入門
kmotohas
2
950
多野優介
tanoyusuke
1
410
VCC 2025 Write-up
bata_24
0
180
空間を設計する力を考える / 20251004 Naoki Takahashi
shift_evolve
PRO
3
330
Trust as Infrastructure
bcantrill
0
320
AI駆動開発を推進するためにサービス開発チームで 取り組んでいること
noayaoshiro
0
150
AI Agentと MCP Serverで実現する iOSアプリの 自動テスト作成の効率化
spiderplus_cb
0
480
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
3
20k
E2Eテスト設計_自動化のリアル___Playwrightでの実践とMCPの試み__AIによるテスト観点作成_.pdf
findy_eventslides
0
100
PLaMoの事後学習を支える技術 / PFN LLMセミナー
pfn
PRO
9
3.8k
Featured
See All Featured
Making Projects Easy
brettharned
119
6.4k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.7k
Done Done
chrislema
185
16k
We Have a Design System, Now What?
morganepeng
53
7.8k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
61k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
19
1.2k
Rails Girls Zürich Keynote
gr2m
95
14k
Being A Developer After 40
akosma
91
590k
BBQ
matthewcrist
89
9.8k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
960
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.7k
The Pragmatic Product Professional
lauravandoore
36
6.9k
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