Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
tparseでgo testの出力を見やすくする
Search
utagawa kiki
December 03, 2025
Programming
2
260
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
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
4
780
自動で //nolint を挿入する取り組み / Gopher's Gathering
utgwkk
1
1.5k
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
2.9k
君たちはどうコードをレビューする (される) か / 大吉祥寺.pm
utgwkk
21
16k
Dive into gomock / Go Conference 2024
utgwkk
14
8.2k
Goでリフレクションする、その前に / Kansai.go #1
utgwkk
4
3.6k
Go製Webアプリケーションのエラーとの向き合い方大全、あるいはやっぱりスタックトレース欲しいやん / Kyoto.go #50
utgwkk
7
4.2k
ありがとう、create-react-app
utgwkk
4
12k
mockgenによるモック生成を高速化するツール bulkmockgenのご紹介 / Kyoto.go #43
utgwkk
2
2.5k
Other Decks in Programming
See All in Programming
Cap'n Webについて
yusukebe
0
140
AIコーディングエージェント(Gemini)
kondai24
0
260
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
150
Denoのセキュリティに関する仕組みの紹介 (toranoana.deno #23)
uki00a
0
130
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
8
3.2k
ZOZOにおけるAI活用の現在 ~モバイルアプリ開発でのAI活用状況と事例~
zozotech
PRO
9
5.9k
ハイパーメディア駆動アプリケーションとIslandアーキテクチャ: htmxによるWebアプリケーション開発と動的UIの局所的適用
nowaki28
0
440
愛される翻訳の秘訣
kishikawakatsumi
3
340
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
1.6k
Microservices rules: What good looks like
cer
PRO
0
1.6k
大規模Cloud Native環境におけるFalcoの運用
owlinux1000
0
180
AI時代を生き抜く 新卒エンジニアの生きる道
coconala_engineer
1
390
Featured
See All Featured
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.7k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
320
The untapped power of vector embeddings
frankvandijk
1
1.5k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.3k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
0
2.2k
WCS-LA-2024
lcolladotor
0
380
The Invisible Side of Design
smashingmag
302
51k
Practical Orchestrator
shlominoach
190
11k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
130
sira's awesome portfolio website redesign presentation
elsirapls
0
87
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
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