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
testingを眺める
Search
matumoto
August 30, 2025
Programming
1
180
testingを眺める
会津大学Zli OB/OG LT 2025 in Tokyo 発表資料
-
https://zli.connpass.com/event/363467/
matumoto
August 30, 2025
Tweet
Share
More Decks by matumoto
See All by matumoto
Go標準パッケージのI/O処理をながめる
matumoto
0
210
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
670
Goトランザクション処理
matumoto
1
72
いまいちどスライスの 挙動を見直してみる
matumoto
0
380
Go1.22のリリース予定の機能を見る
matumoto
0
77
GoのUnderlying typeについて
matumoto
0
220
Typed-nilについて
matumoto
0
360
GoのType Setsという概念
matumoto
0
43
GoのRateLimit処理の実装
matumoto
0
460
Other Decks in Programming
See All in Programming
20260315 AWSなんもわからん🥲
chiilog
2
150
Goの型安全性で実現する複数プロダクトの権限管理
ishikawa_pro
2
340
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
420
文字コードの話
qnighy
44
17k
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
240
エンジニアの「手元の自動化」を加速するn8n 2026.02.27
symy2co
0
160
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
520
Kubernetesでセルフホストが簡単なNewSQLを求めて / Seeking a NewSQL Database That's Simple to Self-Host on Kubernetes
nnaka2992
0
110
猫の手も借りたい!ので AIエージェント猫を作って社内に放した話 Claude Code × Container Lambda の Slack Bot "DevNeko"
naramomi7
0
260
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
540
ロボットのための工場に灯りは要らない
watany
10
2.9k
PostgreSQL を使った快適な go test 環境を求めて
otakakot
0
550
Featured
See All Featured
Designing for Timeless Needs
cassininazir
0
160
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
260
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Unsuck your backbone
ammeep
672
58k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
480
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
Technical Leadership for Architectural Decision Making
baasie
3
290
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
390
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
The Limits of Empathy - UXLibs8
cassininazir
1
260
Making Projects Easy
brettharned
120
6.6k
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 もおもしろい