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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
matumoto
August 30, 2025
Programming
210
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
430
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
780
Goトランザクション処理
matumoto
1
85
いまいちどスライスの 挙動を見直してみる
matumoto
0
410
Go1.22のリリース予定の機能を見る
matumoto
0
89
GoのUnderlying typeについて
matumoto
0
230
Typed-nilについて
matumoto
0
380
GoのType Setsという概念
matumoto
0
56
GoのRateLimit処理の実装
matumoto
0
500
Other Decks in Programming
See All in Programming
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.4k
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
3
800
初めてのKubernetes 本番運用でハマった話
oku053
0
120
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
160
どこまでゆるくて許されるのか
tk3fftk
0
470
act2-costs.pdf
sumedhbala
0
110
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
460
Haskell/Servantを通してWebミドルウェアを捉え直す
pizzacat83
1
480
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.3k
1年で人数1.5倍、PR数5.5倍増。 品質とアウトカムはどうなったか、 何が効いたか
ike002jp
0
120
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
200
OS アップデート対応の取り組み方がもっと共有されてほしい
andpad
0
110
Featured
See All Featured
Site-Speed That Sticks
csswizardry
13
1.2k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.6k
From π to Pie charts
rasagy
0
230
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
220
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Test your architecture with Archunit
thirion
1
2.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.7k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
Agile that works and the tools we love
rasmusluckow
331
22k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
270
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 もおもしろい