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
270
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
認証・認可の基本を学ぼう前編
kouyuume
0
270
Vibe codingでおすすめの言語と開発手法
uyuki234
0
110
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
8
3.3k
FluorTracer / RayTracingCamp11
kugimasa
0
250
バックエンドエンジニアによる Amebaブログ K8s 基盤への CronJobの導入・運用経験
sunabig
0
170
Microservices rules: What good looks like
cer
PRO
0
1.6k
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
230
宅宅自以為的浪漫:跟 AI 一起為自己辦的研討會寫一個售票系統
eddie
0
520
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
7
2.3k
公共交通オープンデータ × モバイルUX 複雑な運行情報を 『直感』に変換する技術
tinykitten
PRO
0
160
Context is King? 〜Verifiability時代とコンテキスト設計 / Beyond "Context is King"
rkaga
10
1.4k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
270
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
698
190k
Building Applications with DynamoDB
mza
96
6.8k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Faster Mobile Websites
deanohume
310
31k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
89
Code Review Best Practice
trishagee
74
19k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
0
1.8k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
100
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Typedesign – Prime Four
hannesfritz
42
2.9k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
160
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