CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

gotestsum

$ gotestsum 社区开源 低风险
gotestyourself · 代码托管与研发协同 · Apache-2.0 · macos / linux / windows

gotestsum 封装 go test -json,提供清晰的终端摘要、基于 --rerun-fails 的失败重试,以及 --jsonfile 和 --junitfile 机器可读报告。非交互执行与明确的退出码非常适合 Agent 验证 Go 代码变更。

FCRS-1.0 综合评分
86 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install gotestsum
CLI vs MCP 选型建议 仅 CLI 可用

本地 Go 测试运行器,与代码仓库和 go 工具链强绑定;Agent 应在工作区直接调用 gotestsum。

Agent 友好度体检单

✓ 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
✓ 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 22 / 25

支持 --format standard-json、--jsonfile、--junitfile、NO_COLOR 及非交互退出码,但 Agent 需避免使用 --watch。

  • Structured --format standard-json and --jsonfile output
  • Compact --format pkgname-and-test-fails reduces log noise
安全与权限边界 22 / 25

无凭证或远程写入风险;仅执行本地 go test 并只在显式传入 --junitfile 或 --jsonfile 时写文件。

  • No auth required; strictly local workspace execution
安装与运行摩擦 14 / 15

单一静态 Go 二进制,可通过 brew install gotestsum 与 go install 在 macOS、Linux 与 Windows 安装。

  • Cross-platform binary with Homebrew and Go module install
能力覆盖与边际价值 13 / 15

相比原生 go test 显著增强,提供仅失败摘要、--rerun-fails 重试与 JUnit/JSON 报告。

  • Built-in --rerun-fails and JUnit/JSON reporters
维护与来源背书 8 / 10

由社区维护的高人气 Go 工具(gotestyourself/gotestsum),采用 Apache-2.0 协议。

  • Widely adopted in Go CI pipelines
文档与可验证性 7 / 10

--help 输出清晰,README 对各格式化器与参数说明直观。

  • Self-contained --help flag reference

安全边界、鉴权与放权指南

鉴权方式
无需鉴权
凭证存储位置

无需凭证;直接调用本地 go 工具链运行本地测试套件。

潜在副作用
只读查询 本地写入
费用与配额提示

Apache-2.0 开源 CLI,完全免费。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# gotestsum Agent Rules
- Prefer `--format pkgname-and-test-fails` or `--format standard-json` with `NO_COLOR=1`.
- Avoid `--watch` mode inside non-interactive agent loops.
- Pass explicit package targets after `--` when scoping fast test runs.

Agent 高频安全命令配方

只读查询(安全推荐)

以 JSON 事件流运行 Go 测试
gotestsum --format standard-json -- ./...

直接输出 go test -json 结构化事件流,无需写入报告文件。

无颜色输出精简包级摘要
NO_COLOR=1 gotestsum --format pkgname-and-test-fails -- ./...

仅输出各包状态与失败用例详情,大幅节省 Agent 上下文。

受控写入与预演

运行测试并写入 JUnit 与 JSON 产物
gotestsum --format dots --junitfile reports/junit.xml --jsonfile reports/events.json -- ./...

将结构化的 JUnit XML 与 JSON 测试事件日志保存到 reports/ 供后续检查。

核心优势

  • + --format pkgname-and-test-fails 能将失败输出压缩到最适合 LLM 上下文的长度。
  • + 同时支持 go test -json 流(--jsonfile)与 CI 标准的 --junitfile XML。
  • + 支持 --rerun-fails 自动排查偶发不稳定测试。

注意事项与踩坑点

  • ! 交互式 --watch 模式会持续阻塞,无头运行时切勿使用。
  • ! 依赖本地已安装且匹配项目 go.mod 的 go 工具链。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI