golang-testing
仓库创建 2026年6月24日最近提交 21 天前SkillHot 收录 21 天前
▸ 精选理由
提供具体模式与触发场景,能显著提升 Go 项目测试质量与一致性。
这个 Skill 做什么
定义 Go 测试惯用模式(表格驱动、子测试、benchmark、模糊测试等)。
讲解 Go 语言里写测试的惯用模式:以 table-driven 为主,配合子测试、benchmark、fuzzing 和覆盖率实践,遵循 TDD 思路。用在为函数或方法补充测试、创建 benchmark 或模糊测试、提升覆盖率时。强调 idiomatic Go 的写法和可复用模板,会给出具体代码示例和组织建议。
▸ 展开 SKILL.md 英文原文
Go testing patterns including table-driven tests, subtests, benchmarks, fuzzing, and test coverage. Follows TDD methodology with idiomatic Go practices. Use when this capability is needed.
0
Stars
0
Forks
40
仓库内 Skill
+0
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/tomevault-io/skills-registry/main/0xbb2b--bb-spec--golang-testing/SKILL.md或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/tomevault-io/skills-registry/main/0xbb2b--bb-spec--golang-testing/SKILL.md"SKILL.MD 节选查看完整文件 ↗
# Go 测试模式
Go 语言测试的惯用法与组织方式,配合 `tdd-workflow` skill 的通用纪律使用。
## 触发与跳过
**TRIGGER**:编写 / 审查 Go 函数或方法、补充测试覆盖、创建 benchmark / fuzz test。
**SKIP**:生成代码、vendor、纯配置。
---
## 1. Table-Driven Tests(默认模式)
所有 Go 测试优先使用 table-driven 模式:
```go
func TestParseConfig(t *testing.T) {
tests := []struct {
name string
input string
want *Config
wantErr bool
}{
{"valid", `{"host":"localhost"}`, &Config{Host: "localhost"}, false},
{"invalid JSON", `{bad}`, nil, true},
{"empty", "", nil, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := ParseConfig(tt.input)
if tt.wanvia SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有