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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
62
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
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
460
株式会社 Sun terras カンパニーデック
sunterras
0
1.9k
kintone + ローカルLLM = ?
akit37
0
120
モジュラモノリスにおける境界をGoのinternalパッケージで守る
magavel
0
2.9k
「ブロックテーマでは再現できない」は本当か?
inc2734
0
1.1k
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
7
1.2k
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
360
PJのドキュメントを全部Git管理にしたら、一番喜んだのはAIだった
nanaism
0
220
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
150
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
200
オブザーバビリティ駆動開発って実際どうなの?
yohfee
2
560
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
3
320
Featured
See All Featured
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
Designing for humans not robots
tammielis
254
26k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Amusing Abliteration
ianozsvald
0
120
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
140
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
130
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
370
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Mobile First: as difficult as doing things right
swwweet
225
10k
From π to Pie charts
rasagy
0
140
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