Getting it into your agent
It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.
git clone --depth 1 https://github.com/echoVic/boss-skillnpx agentmods add skills/echovic/boss-skill/unit-testingWrote 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/skills/echovic/boss-skill/unit-testing)<a href="https://agentmods.dev/skills/echovic/boss-skill/unit-testing"><img src="https://agentmods.dev/badge/skills/echovic/boss-skill/unit-testing/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/skills/echovic/boss-skill/unit-testing"><img src="https://agentmods.dev/badge/skills/echovic/boss-skill/unit-testing.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.00050 | $0.05326 |
| Opus 5.5 | $0.00020 | $0.02130 |
| Sonnet 5.5 | $0.00010 | $0.01065 |
| Haiku 4.5 | $0.00005 | $0.00533 |
Grade A, and why
qa/unit-testing 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 5d 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.
How it starts
The opening of the file, as written. The whole thing — 714 lines — stays where its author put it; the contents beside it link to each section on GitHub.
单元测试方法论
单元测试的定义与原则
单元测试验证最小可测试单元(函数、方法、类、组件)的行为,隔离外部依赖。
核心原则
| 原则 | 说明 |
|---|---|
| 隔离 | 一个测试只验证一个行为,不依赖其他测试或外部系统 |
| 快速 | 毫秒级执行,全部单元测试应在秒级完成 |
| 确定 | 相同输入多次运行结果一致,不依赖时间/网络/随机数 |
| 可读 | 测试代码即文档,命名清晰表达意图 |
| 独立 | 测试顺序不影响结果,可任意顺序执行 |
什么该做单元测试
| 应该测 | 不应该测 |
|---|---|
| 纯函数 / 工具函数 | 框架内部行为(React 渲染机制) |
| Service 层业务逻辑 | 第三方库本身 |
| 组件渲染与交互(前端) | 配置文件 / 常量 |
| Hook 状态逻辑 | 简单的 getter/setter |
| 校验 / 转换 / 格式化逻辑 | 数据库查询(属于集成测试) |
| 状态机 / 状态转换 | 网络请求(属于集成测试) |
AAA 模式(Arrange-Act-Assert)
每个单元测试遵循三段式结构:
it('applies 10% discount when total > 100', () => {
// Arrange — 准备测试数据和环境
const items = [{ price: 60, quantity: 2 }]; // total = 120
const discount = 0.1;
// Act — 执行被测逻辑
const result = calculateTotal(items, discount);
// Assert — 验证结果
expect(result).toBe(108); // 120 * 0.9
});
命名规范:[期望行为] when [条件] 或 [动作] [结果]
// ✅ 好
it('returns error when email is invalid');
it('calculates total with discount applied');
// ❌ 差
it('should work');
it('test1');
Test Doubles(测试替身)
根据用途选择不同的替身类型:
| 类型 | 用途 | 示例 |
|---|---|---|
| Dummy | 占位,不被调用 | 传一个空对象满足参数签名 |
| Stub | 提供预设返回值 | repo.findById.mockResolvedValue(user) |
| Spy | 记录调用信息 | expect(fn).toHaveBeenCalledWith(arg) |
| Mock | Stub + Spy,验证交互 | mock.calledWith(...) |
| Fake | 简化的真实实现 | 内存数据库替代真实 DB |
何时使用哪种
// Stub:被测代码需要依赖返回值,但不关心调用细节
jest.mock('../repo', () => ({
findById: jest.fn().mockResolvedValue({ id: '1', name: 'Alice' }),
}));
// Spy:需要验证依赖是否被正确调用
const emailSpy = jest.spyOn(emailService, 'send');
await userService.register(user);
expect(emailSpy).toHaveBeenCalledWith(user.email, expect.any(String));
// Fake:需要一个可用但简化的实现
class FakeCache implements Cache {
private store = new Map<string, string>();
async get(k: string) {
return this.store.get(k) ?? null;
}
async set(k: string, v: string) {
this.store.set(k, 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.
- 5d ago First seen · 714 lines · 50 tokens per session scan A e065385b074b
qa/unit-testing is a skill published in the GitHub repository echoVic/boss-skill (544 stars, last pushed yesterday), licensed MIT. It adds 50 tokens to every session and 5,326 once invoked, about $0.0002 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-10-28.
Other skills, from other repositories
web3-testing
Test smart contracts comprehensively using Hardhat and Foundry with unit tests, integration tests, and mainnet forking. Use when testing Solidity contracts, setting up blockchain test suites, or validating DeFi protocols.
temporal-python-testing
Test Temporal workflows with pytest, time-skipping, and mocking strategies. Covers unit testing, integration testing, replay testing, and local development setup. Use when implementing Temporal workflow tests or debugging test failures.
data-quality-frameworks
Implement data quality validation with Great Expectations, dbt tests, and data contracts. Use when building data quality pipelines, implementing validation rules, or establishing data contracts.
go-testing
Trigger: Go tests, go test coverage, Bubbletea teatest, golden files. Apply focused Go testing patterns.
convex-test
Generate convex-test tests for the app's Convex functions.
review-ugc-render
Mandatory pre-publish review gate for a UGC video render. Transcribes the finished render's AUDIO with Whisper and word-diffs it against the approved spoken script, then gates keeping the render as the final version (videoreview) — blocking a render whose generated audio mis-voices a word (e.g. the approved…