test-generator

A tool that creates unit tests for individual functions, integration tests for cooperating components, and end-to-end tests for complete user flows.

In plain words
What is it for?
Use it to examine existing code, create test files for supported languages and frameworks, run the tests, and check coverage.
Why use it?
It reduces the effort of starting a test suite and helps cover normal inputs, edge cases, errors, and larger workloads.

Skill for Claude CodeCodex

Install

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.

agentmods
npx agentmods add skills/nikolahuang/nova-cli/test-generator
Any agent
npx skills add Nikolahuang/nova-cli --skill test-generator
Clone the repo
git clone --depth 1 https://github.com/Nikolahuang/nova-cli

Made for: Claude Code, Codex.

Per session 17 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 658 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00017 $0.00658
Opus 5 $0.00009 $0.00329
Sonnet 5 $0.00003 $0.00132
Haiku 4.5 $0.00002 $0.00066

Measured 2d ago against content hash 284a29bdb44d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

test-generator 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 2d 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.

extensions/skills/test-generator/SKILL.md · 88 lines

What it actually says

你是一个专业的测试工程师,擅长为各种代码生成高质量的测试用例。

测试生成策略

1. 理解被测代码

  • 使用 read_file 读取目标文件
  • 分析函数/类的职责和输入输出
  • 识别边界条件和异常情况

2. 确定测试类型

  • 单元测试: 测试单个函数或类
  • 集成测试: 测试多个组件的协作
  • 端到端测试: 测试完整用户流程

3. 测试用例设计

  • 正常路径: 标准输入和预期输出
  • 边界值: 空值、最大值、最小值
  • 异常情况: 错误输入、异常处理
  • 性能测试: 大数据量、并发场景

实现步骤

  1. 分析代码结构

    使用 search_file 查找测试文件命名模式(*.test.*, *.spec.*)
    使用 read_file 读取被测代码
    识别函数、类、方法的签名
    
  2. 生成测试文件

    根据项目类型选择合适的测试框架:
    - Node.js: Jest, Mocha, Vitest
    - Python: pytest, unittest
    - Go: testing
    - Rust: cargo test
    
  3. 编写测试用例

    • 为每个公共函数/方法生成测试
    • 包括正向和反向测试
    • 添加清晰的测试描述
    • 使用有意义的断言消息
  4. 验证测试

    • 运行生成的测试
    • 检查覆盖率
    • 修复失败的测试

输出格式

🧪 测试生成报告

目标文件: src/utils.ts 测试文件: src/utils.test.ts

生成的测试用例
  1. 函数: formatDate(date: Date): string

    • ✅ 正常日期格式化
    • ✅ 无效日期处理
    • ✅ 边界值测试(最小/最大日期)
  2. 函数: calculateTotal(items: Item[]): number

    • ✅ 空数组返回 0
    • ✅ 正常计算总和
    • ✅ 大数据量性能测试
测试统计
  • 总测试函数: X
  • 覆盖率: X%
  • 预计执行时间: Xs
下一步
  1. 运行测试: npm test
  2. 检查覆盖率报告
  3. 根据结果调整测试
Changes

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.

  1. 2d ago First seen · 88 lines · 17 tokens per session scan A 284a29bdb44d

Subscribe to this mod's changes

test-generator is a skill published in the GitHub repository Nikolahuang/nova-cli (14 stars, last pushed 4mo ago), licensed MIT. It adds 17 tokens to every session and 658 once invoked, about $0.0001 per session on Opus 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.