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
testingを眺める
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
matumoto
August 30, 2025
Programming
230
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
testingを眺める
会津大学Zli OB/OG LT 2025 in Tokyo 発表資料
-
https://zli.connpass.com/event/363467/
matumoto
August 30, 2025
More Decks by matumoto
See All by matumoto
Go標準パッケージのI/O処理をながめる
matumoto
0
520
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
840
Goトランザクション処理
matumoto
1
97
いまいちどスライスの 挙動を見直してみる
matumoto
0
430
Go1.22のリリース予定の機能を見る
matumoto
0
100
GoのUnderlying typeについて
matumoto
0
250
Typed-nilについて
matumoto
0
400
GoのType Setsという概念
matumoto
0
66
GoのRateLimit処理の実装
matumoto
0
550
Other Decks in Programming
See All in Programming
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
1.4k
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
850
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
3
570
続・コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions-again
handlename
0
130
AI時代のシニアエンジニアとは
yosuke_furukawa
PRO
12
9.9k
AI-Powered Domain-Driven Design
ziobrando
0
330
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
170
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
350
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
0
160
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
200
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
120
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
210
Featured
See All Featured
Odyssey Design
rkendrick25
PRO
2
890
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
540
Building Better People: How to give real-time feedback that sticks.
wjessup
371
20k
Designing for Performance
lara
612
70k
WENDY [Excerpt]
tessaabrams
14
40k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.1k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
630
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
450
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
330
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
600
Transcript
testing を眺める 2025-08-30 Zli OB/OG LT
• 学籍番号:s1280136 • 所属:元会津⼤学コンピュータ理⼯学部 • 今興味のあること: • 趣味: ◦ VTuber
◦ スト6を⾒る • ひとこと: ◦ 久々にスライド作成でひりついた matumoto ⾃⼰紹介
Goのtestingパッケージ を⾒ていきます
testing
None
testing パッケージ • testing.T • testing.B • testing.TB • testing.PB
• testing.M • testing.F • いつもお世話になっております
testing.T: テスト
testing.B: ベンチマーク
testing.B: ベンチマーク • testing.T: テスト関連 • testing.B: ベンチマーク関連 • testing.TB
• testing.PB • testing.M • testing.F
testing.TB: バンジーガム testing.TB T B
testing.PB: パラレルベンチマーク
testing.M: テストのメイン関数
testing.F: ファジーテスト
testing.Short() • go test -short 指定の際に分岐できる
testing/ 配下
testing/ 配下 今回は testing/fstest を紹介
testing/fstest
こんな関数を考えてみる
こんな関数を考えてみる
ファイルシステムをいじる関数のテストは⼤変... • そもそもロジックとI/Oを分ければよいのでは? ◦ => いけそう!
None
ロジック Input Output
ロジック Input Output
これでロジックのテストは書きやすい! • ロジック部分は純粋関数なので単体テスト書くだけ! • じゃあ、Inputのときにファイル読み取れるかのテストって...?
これでロジックのテストは書きやすい! • ロジック部分は純粋関数なので単体テスト書くだけ! • じゃあ、Inputのときにファイル読み取れるかのテストって...? ファイルシステムをテストしやすくしよう!
io/fs パッケージの fs.FS インターフェース
io/fs パッケージの fs.ReadFile
os.ReadFile → fs.ReadFile に置き換える
mainではファイルシステムを渡す
テストでは fstest.MapFS を渡す
これでInputのテストは書きやすい! • Input部分は好きに単体テスト書くだけ! • じゃあ、Outputのときにファイル書き出せるかのテストって...? • io/fs.FS は基本読み取りだけ..。 t.TempDir で一時ファイルを作ろう
t.TempDir
テスト⽤の⼀時的なディレクトリを作ってくれる
ファイル書き出し後に、それを確かめる
ファイル書き出し後に、それを確かめる
まとめ • testing.T, testing.B, testing.PB, … は便利 • testing.TB はTとB、両⽅の性質を併せ持つ...♥
• testing/fstest はファイルシステムのテストに便利!
おしまい testing/iotest, testing/synctest もおもしろい