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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
matumoto
August 30, 2025
Programming
200
1
Share
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
400
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
710
Goトランザクション処理
matumoto
1
78
いまいちどスライスの 挙動を見直してみる
matumoto
0
400
Go1.22のリリース予定の機能を見る
matumoto
0
82
GoのUnderlying typeについて
matumoto
0
220
Typed-nilについて
matumoto
0
370
GoのType Setsという概念
matumoto
0
48
GoのRateLimit処理の実装
matumoto
0
470
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
540
継続的な負荷検証を目指して
pyama86
1
830
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
1.1k
cloudnative conference 2026 flyle
azihsoyn
0
130
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
330
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
140
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
260
決定論 vs 確率論:Gemini 3 FlashとTF-IDFを組み合わせた「法規判定エンジン」の構築
shukob
0
160
JAWS-UG横浜 #100 祝・第100回スペシャルAWS は VPC レスの時代へ
maroon1st
0
220
[RubyKaigi 2026] Require Hooks
palkan
1
300
20年以上続くプロダクトでも使い続けられる静的解析ツールを求めて
matsuo_atsushi
0
140
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
28
19k
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Done Done
chrislema
186
16k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
210
My Coaching Mixtape
mlcsv
0
120
Utilizing Notion as your number one productivity tool
mfonobong
4
300
First, design no harm
axbom
PRO
2
1.2k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
180
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
250
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
290
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.8k
Are puppies a ranking factor?
jonoalderson
1
3.4k
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 もおもしろい