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
テストを書いた方が良いところ 書かなくても良いところ
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
ぷらす
March 09, 2019
Technology
320
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
テストを書いた方が良いところ 書かなくても良いところ
CAMPHOR- DAY 2019のLT用資料です。
https://camphor.connpass.com/event/119434/
ぷらす
March 09, 2019
More Decks by ぷらす
See All by ぷらす
AWSの認定資格を受けた話
p1ass
1
520
趣味プロジェクトをリードする技術 / Technology to lead hobby projects
p1ass
21
9.2k
vercel/og-imageを使ったブログOGPの簡単自動生成 / Generate OGP easily using vercel og-image
p1ass
2
1.4k
Webアプリケーションにおける並行処理の難しさ / #Gocon_Sendai
p1ass
4
2.7k
RSSフィードをもっと便利に / Make RSS feeds more convenient #camphor_lt
p1ass
1
16k
うじまる君の生活習慣の乱れを可視化したい! / uzimaru birthday LT
p1ass
2
17k
複数サービスを運用しやすい理想のコンテナ環境をVPS上に構築する #camphor_day / Building ideal container environment on VPS
p1ass
1
9.4k
Kubernetesのイメージタグの更新を楽にするツールを作った / p1ass/mikku - make updating Kubernetes image tags easier
p1ass
1
130
ドメインロジックと 永続化処理を分離する設計改善 を行って得られた知見 / Design improvements that separate domain logic and persistence function
p1ass
1
2.3k
Other Decks in Technology
See All in Technology
あなたの知らないAmazon VPC Route Server/Amazon VPC Route Server you don't know about
masakiokuda
2
240
DevelopersIO 2026 知識の地図を描く ─ オントロジーとは何か?
ishikawa_satoru
1
690
メルペイ 会計システム概要と歴史
mewuto
0
190
IoTデバイスを繋げるプロトコルMatterをAndroidで使用する方法
harutiro
0
120
プロダクト価値を、 チームが使える判断軸に変える
vivion
0
130
Execution in the Kingdom of Agents: Reflections on Abstraction and Complexity
bcantrill
0
880
生成AIと進める探索的データ分析(2026.10.03 第122回Tokyo.R勉強会)
tatamiya
2
1.4k
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
0
160
生成AIで高い生産性を求められて、 悩み、乗り越えた話
mot_techtalk
2
130
AI時代だからこそ推したい!Gitコマンド再入門
munakata
0
160
オブザーバビリティを高める AI エージェント体験を考える / Designing AI Agent Experiences That Enhance Observability
aoto
PRO
2
320
スキルを作る、その前に!複数人で使われるスキルを 作るためのプロセス
junkifurukawa
2
360
Featured
See All Featured
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
390
The Mindset for Success: Future Career Progression
greggifford
PRO
0
530
We Have a Design System, Now What?
morganepeng
55
8.4k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
260
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.3k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
550
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
350
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
760
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Transcript
テストを書いた方が良いところ 書かなくても良いところ 2019/3/9 CAMPHOR- DAY 2019 京都大学 岸 直輝
テストコード書いてますか?
自己紹介 • 岸 直輝 (@plus_kyoto) • 京都大学 工学部 電気電子工学科 2回生
• サーバーサイドの人 (GolangとかPythonとか) • インターンでJava書いてる @ 東京
Q. 何のためにテストを書く?
A. 正しく動作するか確認するため
でもたくさんテストを 書く時間がないよ
どこの部分をテストしたら いいか分からない
大事なこと 動作をきちんと確認したい ところからテストを書いていく
例えば
DBアクセス ☑ CRUDが正しく動作しているか? ☑ 正しいSQLが発行できているか? (JOIN etc.) モックに差し替えられがちで 上のレイヤーのテストでバグが発見されにくい RepositoryとかDAOとか言う部分
認証周り サインインやサインアップ処理 セキュリティチェックは大事! ☑ バリデーションチェックされているか? ☑ 権限に応じたパーミッションが設定されているか?
例外処理 正常系よりも異常系の方が複雑になりがち ☑ 0やnull時の挙動 はチェックしたか?(ヌルポ) ☑ 内部エラーとレスポンスが一致しているか?
逆に書かなくてもいいこともある
ライブラリのラッパー • 有名なOSSなどはしっかりテストが書かれている • 単にライブラリのAPIを呼ぶだけのコードを テストする意味はない テストの重複は時間の無駄
複数から呼ばれる単純な処理 • コード = 仕様 レベルの単純な処理 • バグってても、呼び出し元のテストが 落ちるのでバグ検出可能 ただし、複雑な処理の場合は
原因切り分けのために、テストを書いた方が良さげ
まとめ
まとめ • モック化される部分のテストは書こう • ないがしろにしがちな例外処理はきちんと確認しよう • テストを書かなくてもいい部分があると認識しよう テストを書いてバグにハマらない 快適なコーディング生活を
Thank you Twitter : @plus_kyoto GitHub : naoki-kishi