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
How we make tests
Search
李甘
January 09, 2013
Programming
89
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
How we make tests
a slide for sharing about test
李甘
January 09, 2013
Transcript
12 slides
How we make tests • Test 101 • Make better
tests • Write test friendly code • When & Where we need tests • Sth. else
Test 101 • 如何来测试我们的程序?
Test 101 • 使用代码测试比人更可靠 • Unit tests, Functional tests, Intergration
tests • 如何开始我的测试 ?
Test 101 • 测试的基础 : 验证输入和输出是否符合期望值 • Log, 单步调试 ,
'=', Equal, Assert … and so on • Demo1.
Make better tests • 建立独立最小测试环境 – 测试与代码分离 – Setup &
Teardown – 独立的测试数据
Make better tests • 再多一点 – 独立的测试环境 environment[:test] – 专有的测试方法
testhelper – 有效的组织测试 rake, shell – 使用测试夹具 测试数据无需入库
Make better tests • 依赖外部调用无法测试怎么办 ? – 网络不通 , 调用资金等
– 其他模块出错 , 没开发完 – 我就只想测试自己的部分 等等 • Mock & Stub 帮助你
Write test friendly code • 1 单一职责 • 2 接口分离
• 3 避免耦合太深
Write test friendly code 圆桌讨论 : 怎样写出更容易测试的代码
When & Where we need tests • 等我不忙了就加测试 – 永远有下一个项目
– 越后面成本 ( 包括时间 ) 越高 , 测试质量也越差 • 以前代码太难写测试了 , 等重构了再说 – 测试是重构的基础 – 新的代码还等以后才写测试 ?
When & Where we need tests • 涉及到付费的 谁敢拿钱开玩笑 •
核心业务逻辑 一旦变化会影响多处地方 • 第三方集成 回归 , 你没法控制别人的变化 • 系统中容易变化的地方 测试让每次变化更安全 • 多个 object 协作的地方 每一个的变化都可能出错 • 代码晦涩,难以理解 增加测试是重构的第一步 • 很多判断的地方 逻辑复杂的代表
Sth. else • Watchr & Guard(base on ruby) 让测试守护你的程序 •
CI 持续集成 • TDD&BDD 测试 ( 行为 ) 驱动开发
More Decks by 李甘
See All by 李甘
Learn git
flypiggy
1
320
Other Decks in Programming
See All in Programming
Datadog を OTel にするメリットを考察する — Datadog との併用を実アプリで確かめる / Examining the Benefits of Moving Datadog to OTel — Testing OTel Alongside Datadog in a Real App
seike460
PRO
1
120
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
330
Math.sumPreciseから学ぶ、ECMAScript仕様の数値の種類
syumai
0
1.6k
マルチプロダクトSaaSの アプリ一覧を速くする——複数プロダクトにまたがる「権限行脚」を減らすまで #techramen26conf
mktakuya
1
270
joyful-journey-spring-boot.pdf
hollycummins
0
160
Beyond Chatbots: Agentic UI with Open Standards @W-JAX 2026, München
manfredsteyer
PRO
0
130
自宅サーバはどこまで再現できるのか - Proxmox VE上のVM環境をIaCとバックアップで戻してみた
youto
0
450
AIコーディングをセッションで終わらせない: PHPライブラリ開発におけるコンテキスト承継設計
ickx
0
110
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
240
Spec-driven Development with AI
simas
PRO
0
2.3k
例外からRich Errorsまで Kotlinエラーハンドリングの進化を読み解く
shiita0903
0
260
特急いなほ as a Workflow / 20261107jaws-festa-2026-akita-lt
kasacchiful
PRO
0
110
Featured
See All Featured
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
2
540
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
620
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k
Navigating Team Friction
lara
192
16k
Web Performance Is a Journey [PerfNow 2026]
tammyeverts
3
190
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1.1k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
480
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.5k
Highjacked: Video Game Concept Design
rkendrick25
PRO
2
600
4 Signs Your Business is Dying
shpigford
187
23k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
300