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
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
460
sync/v2 プロポーザルの 背景と sync.Pool について
matumoto
0
800
Goトランザクション処理
matumoto
1
91
いまいちどスライスの 挙動を見直してみる
matumoto
0
430
Go1.22のリリース予定の機能を見る
matumoto
0
92
GoのUnderlying typeについて
matumoto
0
250
Typed-nilについて
matumoto
0
390
GoのType Setsという概念
matumoto
0
62
GoのRateLimit処理の実装
matumoto
0
510
Other Decks in Programming
See All in Programming
MySQLとPostgreSQLって何が違うの?
akagami
0
150
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.4k
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.4k
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
460
ソフトウェアラスタライザ
fadis
1
750
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
240
PHPプロジェクトの結合バランスを可視化する #php_night
kajitack
0
140
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
2
630
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
130
AWS Transform Customによる Spring Boot 2.xから4.xへのVerUp
satoshi256kbyte
2
120
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
「つくるAI」だけではバグは見つからない ~テストに必要な「見つけるAI」を分離させる戦略~
mfunaki
0
210
Featured
See All Featured
Designing for Timeless Needs
cassininazir
1
460
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
630
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
510
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
370
The Mindset for Success: Future Career Progression
greggifford
PRO
0
480
The Limits of Empathy - UXLibs8
cassininazir
1
620
Done Done
chrislema
186
16k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
430
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Faster Mobile Websites
deanohume
310
32k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
300
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
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 もおもしろい