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
660
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
2.4k
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
4
1.2k
自動で //nolint を挿入する取り組み / Gopher's Gathering
utgwkk
1
1.9k
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
3.4k
君たちはどうコードをレビューする (される) か / 大吉祥寺.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
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
8.1k
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
150
CSC307 Lecture 14
javiergs
PRO
0
470
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
560
生成 AI 時代のスナップショットテストってやつを見せてあげますよ(α版)
ojun9
0
240
Unity6.3 AudioUpdate
cova8bitdots
0
140
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
150
AWS Infrastructure as Code の新機能 2025 総まとめ 〜SA 4人による怒涛のデモ祭り〜
konokenj
10
3.4k
OTP を自動で入力する裏技
megabitsenmzq
0
110
米国のサイバーセキュリティタイムラインと見る Goの暗号パッケージの進化
tomtwinkle
2
600
Codex の「自走力」を高める
yorifuji
0
1.2k
Claude Code Skill入門
mayahoney
0
400
Featured
See All Featured
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
460
Building Applications with DynamoDB
mza
96
7k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
240
Optimizing for Happiness
mojombo
378
71k
Navigating Weather and Climate Data
rabernat
0
140
Marketing to machines
jonoalderson
1
5k
The Curious Case for Waylosing
cassininazir
0
270
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.9k
Designing for Timeless Needs
cassininazir
0
170
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
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