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
220
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
440
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
790
Goトランザクション処理
matumoto
1
87
いまいちどスライスの 挙動を見直してみる
matumoto
0
420
Go1.22のリリース予定の機能を見る
matumoto
0
90
GoのUnderlying typeについて
matumoto
0
240
Typed-nilについて
matumoto
0
380
GoのType Setsという概念
matumoto
0
62
GoのRateLimit処理の実装
matumoto
0
500
Other Decks in Programming
See All in Programming
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
4
1.6k
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
210
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.7k
SlackアプリとLambdaの 連携を構築した話
pawn_4_s
1
110
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
4
1.9k
Built Our Own Background Agent at LayerX
layerx
PRO
10
5.3k
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
310
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
160
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
680
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
500
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
540
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.7k
Featured
See All Featured
Embracing the Ebb and Flow
colly
88
5.1k
Designing Experiences People Love
moore
143
24k
Why Our Code Smells
bkeepers
PRO
340
58k
Designing for humans not robots
tammielis
254
26k
Making Projects Easy
brettharned
120
6.7k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
430
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
450
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
890
The Pragmatic Product Professional
lauravandoore
37
7.4k
Navigating Team Friction
lara
192
16k
Done Done
chrislema
186
16k
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 もおもしろい