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
tparseでgo testの出力を見やすくする
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
utagawa kiki
December 03, 2025
Programming
2
550
tparseでgo testの出力を見やすくする
明日から使えるgo test実践テクニック集
https://findy.connpass.com/event/375530/
utagawa kiki
December 03, 2025
Tweet
Share
More Decks by utagawa kiki
See All by utagawa kiki
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
68
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
4
1k
自動で //nolint を挿入する取り組み / Gopher's Gathering
utgwkk
1
1.8k
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
3.3k
君たちはどうコードをレビューする (される) か / 大吉祥寺.pm
utgwkk
21
17k
Dive into gomock / Go Conference 2024
utgwkk
14
8.4k
Goでリフレクションする、その前に / Kansai.go #1
utgwkk
4
3.7k
Go製Webアプリケーションのエラーとの向き合い方大全、あるいはやっぱりスタックトレース欲しいやん / Kyoto.go #50
utgwkk
7
4.3k
ありがとう、create-react-app
utgwkk
4
12k
Other Decks in Programming
See All in Programming
TROCCOで実現するkintone+BigQueryによるオペレーション改善
ssxota
0
110
Head of Engineeringが現場で回した生産性向上施策 2025→2026
gessy0129
PRO
0
200
個人開発は儲からない - それでも開発開始1ヶ月で300万円売り上げた方法
taishiyade
0
120
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
360
Go1.26 go fixをプロダクトに適用して困ったこと
kurakura0916
0
300
浮動小数の比較について
kishikawakatsumi
0
350
Rubyと楽しいをつくる / Creating joy with Ruby
chobishiba
0
200
CSC307 Lecture 14
javiergs
PRO
0
430
Raku Raku Notion 20260128
hareyakayuruyaka
0
420
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
180
AI主導でFastAPIのWebサービスを作るときに 人間が構造化すべき境界線
okajun35
0
310
AI駆動開発の本音 〜Claude Code並列開発で見えたエンジニアの新しい役割〜
hisuzuya
1
370
Featured
See All Featured
Become a Pro
speakerdeck
PRO
31
5.8k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
280
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Six Lessons from altMBA
skipperchong
29
4.2k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
130
We Are The Robots
honzajavorek
0
180
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
140
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
A better future with KSS
kneath
240
18k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
220
Transcript
tparseでgo testの出力を 見やすくする id:utgwkk / @utgwkk (うたがわきき) 2025/12/3 明日から使えるgo test実践テクニック集
1
自己紹介 • うたがわきき (@utgwkk) • 株式会社はてな ◦ Webアプリケーションエンジニア • 好きなパッケージはreflect
2
go testのいいところ • 標準ライブラリ・ツールでテストできる ◦ testingパッケージを使ってテストを書けばよい ◦ go testコマンドを実行すればよい 3
go testのいまいちなところ • どのテストが失敗したのか見づらい ◦ サマリはいちおう表示されるが ◦ テストが多くなってくると特に顕著 ◦ -v
オプションを付けると顕著 4
どこで落ちた? === RUN TestFoo main_test.go:8: Foo --- PASS: TestFoo (0.00s)
=== RUN TestBaz main_test.go:12: failed! --- FAIL: TestBaz (0.00s) === RUN TestBar --- PASS: TestBar (0.00s) FAIL exit status 1 FAIL github.com/owner/repo 0.228s 5
どこで落ちた? === RUN TestFoo main_test.go:8: Foo --- PASS: TestFoo (0.00s)
=== RUN TestBaz main_test.go:12: failed! --- FAIL: TestBaz (0.00s) === RUN TestBar --- PASS: TestBar (0.00s) FAIL exit status 1 FAIL github.com/owner/repo 0.228s 6
そこでtparse • https://github.com/mfridman/tparse • go testの出力を整形するツール 7
8 画像はREADMEより引用
9 画像はREADMEより引用
基本的な使い方 (1) set -o pipefail && go test ./... -json
| tparse -all 10
基本的な使い方 (2) go test ./... -json > test.json tparse -all
-file=test.json 11
CIでの注意事項 12 • 異常終了したら以降のステップをskipする設定に なっていがち ◦ テスト失敗するとtparseで整形されない!! • 対策 ◦
go testとtparseを1つのstepで実行する ◦ go testが失敗しても後続のstepが実行されるようにする ▪ GitHub Actionsならif: always()
GitHub ActionsのJob summaryを活用する ジョブの実行結果をMarkdown形式で整形・表示できる - run: | go test -v
-json ./... | tee output.jsonl tparse -format markdown -file output.jsonl > $GITHUB_STEP_SUMMARY 13
14 tparseのCIの実行ログから引用
あわせて読みたい • Goのテスト結果をtparseで整形する ・GitHub ActionsのJob Summaryと組み合 わせる - 私が歌川です 15
tparseの仕組み • go test -jsonの出力をパースしている 16
go test -json • テストの出力をJSON形式で得られる • テスト結果をプログラマブルに解析・パース するのに便利 17
go test -v 18 === RUN TestDummy --- PASS: TestDummy
(0.00s) PASS ok github.com/owner/repo 0.492s
go test -json {"Time":"2025-08-25T22:14:43.946504+09:00","Action":"start","Package":"github.com/owner/repo"} {"Time":"2025-08-25T22:14:44.522307+09:00","Action":"run","Package":"github.com/owner/repo","Test":"TestDummy "} {"Time":"2025-08-25T22:14:44.522455+09:00","Action":"output","Package":"github.com/owner/repo","Test":"TestDu mmy","Output":"=== RUN TestDummy\n"}
{"Time":"2025-08-25T22:14:44.522499+09:00","Action":"output","Package":"github.com/owner/repo","Test":"TestDu mmy","Output":"--- PASS: TestDummy (0.00s)\n"} {"Time":"2025-08-25T22:14:44.522507+09:00","Action":"pass","Package":"github.com/owner/repo","Test":"TestDumm y","Elapsed":0} {"Time":"2025-08-25T22:14:44.522513+09:00","Action":"output","Package":"github.com/owner/repo","Output":"PASS \n"} {"Time":"2025-08-25T22:14:44.522989+09:00","Action":"output","Package":"github.com/owner/repo","Output":"ok \tgithub.com/owner/repo\t0.576s\n"} {"Time":"2025-08-25T22:14:44.52587+09:00","Action":"pass","Package":"github.com/owner/repo","Elapsed":0.579} 19
JSONのフィールド 20 • Actionにイベントの種類が入る ◦ start/run/output/pass/(fail) • Actionに応じてJSONのフィールドが変わる
test2json • https://pkg.go.dev/cmd/test2json • test2jsonというコマンドでログ→JSONの変 換だけを行うこともできる ◦ cat output.log |
go tool test2json 21
あわせて読みたい • go test -json そして testing.T.Attr 22
今日の発表のまとめ 23 • tparseでgo testの結果を整形できる • tparseはgo test -jsonの出力をパースする
株式会社はてなのエンジニア求人一覧 https://findy-code.io/companies/1096/jobs 24
hatena.co.jp/recruit 25 25
想定質問・時間が余ったとき用 • set -o pipefailについて • ツールの見つけ方 • gotestsumとの比較 •
tparseが使われている様子を詳しく見たい 26
set -o pipefailについて (1) • 通常、パイプをつなげたコマンドのうち最後 の終了コードが使われる ◦ cmd1 |
cmd2のうちcmd1が異常終了、cmd2が正常 終了した場合、cmd1 | cmd2は正常終了扱いになる 27
set -o pipefailについて (2) • set -o pipefailを実行することで、この挙動を変更 できる ◦
cmd1が異常終了したらcmd1 | cmd2も異常終了扱いになる • 参考 ◦ ネコでもわかる set ±o pipefail - Hirosaji Tech Blog 🍙 28
ツールの見つけ方 • awesome-goを見る ◦ https://github.com/avelino/awesome-go • 会社で教えてもらう • Goコミュニティで教えてもらう 29
gotestsumとの比較 (1) • https://github.com/gotestyourself/gotestsum • gotestsumのほうが多機能 ◦ watchモードでテストできる ◦ テスト終了後に実行するコマンドを指定できる
◦ etc. • tparseはテスト結果の整形に特化している 30
gotestsumとの比較 (2) • シンプルであることの旨み ◦ 実装を気軽に読める ◦ 責務がはっきりしている ◦ 最悪、脱出しやすい
31
tparseが使われている様子を詳しく見たい • tparseのリポジトリのCIで使われている ◦ GitHub Actions workflowの定義 ◦ CIの実行ログ 32