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
190
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
370
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
680
Goトランザクション処理
matumoto
1
77
いまいちどスライスの 挙動を見直してみる
matumoto
0
390
Go1.22のリリース予定の機能を見る
matumoto
0
80
GoのUnderlying typeについて
matumoto
0
220
Typed-nilについて
matumoto
0
360
GoのType Setsという概念
matumoto
0
46
GoのRateLimit処理の実装
matumoto
0
470
Other Decks in Programming
See All in Programming
テレメトリーシグナルが導くパフォーマンス最適化 / Performance Optimization Driven by Telemetry Signals
seike460
PRO
2
200
見せてもらおうか、 OpenSearchの性能とやらを!
shunta27
1
170
How to stabilize UI tests using XCTest
akkeylab
0
150
存在論的プログラミング: 時間と存在を記述する
koriym
5
740
PHPで TLSのプロトコルを実装してみる
higaki_program
0
720
今からFlash開発できるわけないじゃん、ムリムリ! (※ムリじゃなかった!?)
arkw
0
170
2026-03-27 #terminalnight 変数展開とコマンド展開でターミナル作業をスマートにする方法
masasuzu
0
270
飯MCP
yusukebe
0
450
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.5k
Feature Toggle は捨てやすく使おう
gennei
0
400
PHP でエミュレータを自作して Ubuntu を動かそう
m3m0r7
PRO
2
160
20260315 AWSなんもわからん🥲
chiilog
2
180
Featured
See All Featured
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.8k
Building an army of robots
kneath
306
46k
Exploring anti-patterns in Rails
aemeredith
3
300
Information Architects: The Missing Link in Design Systems
soysaucechin
0
850
Tell your own story through comics
letsgokoyo
1
880
We Are The Robots
honzajavorek
0
210
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
94
Odyssey Design
rkendrick25
PRO
2
560
Optimizing for Happiness
mojombo
378
71k
From π to Pie charts
rasagy
0
160
How to build a perfect <img>
jonoalderson
1
5.3k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
160
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 もおもしろい