Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
git clone --depth 1 https://github.com/xyzbit/AI-CodingWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/xyzbit/ai-coding/d-test-unit-test)<a href="https://agentmods.dev/rules/xyzbit/ai-coding/d-test-unit-test"><img src="https://agentmods.dev/badge/rules/xyzbit/ai-coding/d-test-unit-test/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/xyzbit/ai-coding/d-test-unit-test"><img src="https://agentmods.dev/badge/rules/xyzbit/ai-coding/d-test-unit-test.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00006 | $0.00871 |
| Opus 5.5 | $0.00002 | $0.00348 |
| Sonnet 5.5 | $0.00001 | $0.00174 |
| Haiku 4.5 | $0.00001 | $0.00087 |
Grade A, and why
d-test-unit-test scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
Golang 单元测试规范
命名规范
- 测试文件命名:
xxx_test.go - 测试函数命名:
Test${被测试函数名} - 基准测试函数:
Benchmark${被测试函数名} - 示例函数:
Example${被测试函数名}
测试用例组织
- 使用
t.Run()进行子测试分组 - 每个测试场景应该有清晰的描述
- 使用表驱动测试方式组织多个测试用例
- 测试覆盖率要求 > 60%
测试代码结构
func TestXxx(t *testing.T) {
// 1. 准备测试数据
type args struct {
// 输入参数
}
tests := []struct {
name string // 测试用例名称
args args // 输入参数
want interface{} // 期望输出
wantErr bool // 是否期望错误
}{
// 测试用例列表
}
// 2. 执行测试
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// 3. 准备测试环境(如果需要)
// 4. 执行被测试函数
// 5. 验证结果
// 6. 清理测试环境(如果需要)
})
}
}
测试原则
- 单一职责:每个测试用例只测试一个功能点
- 独立性:测试用例之间相互独立,不应该有依赖关系
- 可重复:测试结果应该是稳定的,多次运行结果一致
- 简单明了:测试代码应该简单易懂,避免复杂的逻辑
Mock 使用规范
- 优先使用接口进行依赖注入,便于 mock
- 推荐使用
go-mock、testify/mock等工具 - Mock 对象应该在测试函数开始时创建,结束时销毁
断言规范
- 推荐使用
testify/assert包进行断言 - 使用恰当的断言函数,如:
assert.Equal(t, expected, actual)assert.NoError(t, err)assert.True(t, condition)
最佳实践
- 测试文件与源文件放在同一目录下
- 优先测试接口而不是实现细节
- 避免测试私有方法,通过公共接口测试
- 合理使用测试辅助函数减少重复代码
- 及时清理测试产生的临时资源
- 编写测试时考虑边界条件和异常场景
示例
func TestCalculator_Add(t *testing.T) {
type args struct {
a, b int
}
tests := []struct {
name string
args args
want int
wantErr bool
}{
{
name: "正常相加",
args: args{a: 1, b: 2},
want: 3,
},
{
name: "负数相加",
args: args{a: -1, b: 1},
want: 0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := NewCalculator()
got := c.Add(tt.args.a, tt.args.b)
assert.Equal(t, tt.want, got)
})
}
}
运行测试
- 运行所有测试:
go test ./... - 运行指定包测试:
go test ./pkg/... - 运行指定函数:
go test -run TestXxx - 显示详细日志:
go test -v
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3mo ago First seen · 115 lines · 6 tokens per session scan A 9a8c0e3d52bb
d-test-unit-test is a cursor rule published in the GitHub repository xyzbit/AI-Coding (21 stars, last pushed 1y ago), licensed Apache-2.0. It adds 6 tokens to every session and 871 once invoked, about $0.0000 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
d-test-unit-test compared with cursor rules from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| d-test-unit-testxyzbit/AI-Coding | Cursor rule | 21 | 1y ago | Apache-2.0 | A | 6 | Cursor |
| gonavi-goSyngnat/GoNavi | Cursor rule | 2.1k | yesterday | Apache-2.0 | A | 0 | Cursor |
| goPatrickJS/awesome-cursorrules | Cursor rule | 41k | 6mo ago | CC0-1.0 | A | 290 | Cursor |
| goadonai-labs/agent-runway | Cursor rule | 2 | 6d ago | MIT | A | 0 | Cursor |
| schema_test_implementation_guidekaptinlin/gozod | Cursor rule | 25 | 4mo ago | MIT | A | 4,495 | Cursor |
| mockeryhiromaily/go-crypto-wallet | Cursor rule | 129 | 7mo ago | MIT | A | 0 | Cursor |
| go-testhiromaily/docs-ssot | Cursor rule | 2 | 7mo ago | MIT | A | 0 | Cursor |