test-creator
- Repo stars 310
- Author updated Live
- Author repo xiaozhi-client
- Domain
- AI
- Compatible agents
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- Trust score
- 88 / 100 · community maintained
- Author / version / license
- @shenjingnan · no license declared
- Token usage
- Lean
- Setup complexity
- Plug-and-play
- External API key
- Not required
- Operating systems
- Unspecified (assume cross-platform)
- Runtime requirements
- No special requirements
- Permissions
-
- Read-only
- Write / modify
- Network behavior
- Local-only
- Install commands
- 26 variants
Profile is derived at build time from SKILL.md and install vectors. Subject to drift from author intent.
Heads up: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: test-creator
description: 我是一个测试创建专家,专门为 xiaozhi-client 项目生成符合标准的测试用例。 使用格式:/test-create [测试类型] [目标文件或模块] import { describ…
category: ai
runtime: no special runtime
---
# test-creator output preview
## PART A: Task fit
- Use case: 我是一个测试创建专家,专门为 xiaozhi-client 项目生成符合标准的测试用例。 使用格式:/test-create [测试类型] [目标文件或模块] import { describe, expect, it, beforeEach, afterEach, vi } from "vitest"; // 导入要测试的模块(使用项目路径别名) import { TargetClass, TargetFunction } from "@/module/target-module"; runs entirely locally. Works with Claude Code, Cursor, Cline and 23 more..
- Inputs: target material, constraints, expected output, and acceptance criteria.
- Evidence boundary: follow “我的能力 / 使用方式 / 支持的测试类型” and do not present inference as author intent.
## PART B: Execution result
- **01** The card summarizes the use case; runtime output centers on “我是一个测试创建专家,专门为 xiaozhi-client 项目生成符合标准的测试用例。 使用格式:/test-create [测试类型] [目标文件或模块] import { describe, expect, it, beforeEach, afterEach, vi } from "vitest"; // 导入要测试的模块(使用项目路径别名) import { TargetClass, TargetFunction } from "@/module/target-module"; runs entirely locally. Works with Claude Code, Cursor, Cline and 23 more.”.
- **02** When the source has headings, the agent prioritizes “我的能力 / 使用方式 / 支持的测试类型” so the result follows the author’s structure.
- **03** Typical output includes task judgment, concrete steps, required commands or file edits, validation, and follow-up options.
- **04** Risk context follows the fingerprint: read files, write/modify files; mostly runs locally; usually needs no extra API key.
## Running Rules
- read files, write/modify files; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding scope.
- Return the result, validation criteria, and next iteration options. The source mentions slash commands such as `/test-create`; use them first when your agent supports command triggers.
Name target files or source material, expected output, forbidden changes, and whether network or shell access is allowed. Permission fingerprint: read files, write/modify files.
Start with a small task and check whether the result follows “我的能力 / 使用方式 / 支持的测试类型”. Inspect diffs, logs, previews, or tests before expanding scope.
Confirm the final output includes a concrete result, evidence, and next action. If it stays generic, tighten inputs, boundaries, and acceptance criteria.
---
name: test-creator
description: 我是一个测试创建专家,专门为 xiaozhi-client 项目生成符合标准的测试用例。 使用格式:/test-create [测试类型] [目标文件或模块] import { describ…
category: ai
source: shenjingnan/xiaozhi-client
---
# test-creator
## When to use
- 我是一个测试创建专家,专门为 xiaozhi-client 项目生成符合标准的测试用例。 使用格式:/test-create [测试类型] [目标文件或模块] import { describe, expect, it, beforeE…
- Use it when the task has clear inputs, repeatable steps, and validation criteria.
## What to provide
- Target material, scope, expected result, and forbidden changes.
- Whether network, commands, file writes, or external services are allowed.
## Execution rules
- Organize steps around “我的能力 / 使用方式 / 支持的测试类型” and keep inference separate from source facts.
- read files, write/modify files; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding the task.
## Output requirements
- Return the deliverable, key evidence, validation method, and next action.
- Mark missing information as unknown; do not invent commands, platforms, or dependencies. The author source anchors workflow facts; repository files anchor sources and commands; Fluxly only adds fit, limitations, and quality judgment.
skill "test-creator" {
input -> user goal + target files + boundaries + acceptance criteria
context -> 我的能力 / 使用方式 / 支持的测试类型
rules -> SKILL.md triggers / order / output contract
runtime -> no special runtime | read files, write/modify files | mostly runs locally
guardrails -> usually needs no extra API key + small-sample validation + diff/log review
output -> copyable result + checklist + next iteration
} 测试创建技能
我是一个测试创建专家,专门为 xiaozhi-client 项目生成符合标准的测试用例。
我的能力
当你需要创建测试用例时,我会:
- 分析测试需求 - 确定测试范围、场景和 Mock 策略
- 生成测试文件 - 创建符合项目标准的完整测试文件
- 确保覆盖率 - 满足 80% 覆盖率要求
- 执行质量检查 - 验证测试代码质量
使用方式
使用格式:/test-create [测试类型] [目标文件或模块]
示例:
/test-create mcp-tool "core/unified-server"/test-create cli-command "cli/commands/start"/test-create transport "transports/websocket-adapter"/test-create utility "utils/config-parser"/test-create type "types/xiaozhi-config"/test-create service "managers/connection-manager"
支持的测试类型
mcp-tool - MCP 工具测试
- 测试重点:参数验证、API 调用、设备查找、错误处理
- Mock 对象:外部服务、设备状态数据
service - 服务类测试
- 测试重点:业务逻辑、数据转换、异常处理
- Mock 对象:外部 API、数据库连接
utility - 工具函数测试
- 测试重点:输入输出、边界值、类型安全
- Mock 对象:通常无需 Mock
type - 类型定义测试
- 测试重点:类型构造函数、类型守卫、错误类型
- Mock 对象:根据具体需求定
cli-command - CLI 命令测试
- 测试重点:参数解析、配置加载、错误输出
- Mock 对象:process.argv、console.log、文件系统
transport - 传输层适配器测试
- 测试重点:连接建立、消息收发、错误处理、重连
- Mock 对象:WebSocket、HTTP 服务器
测试文件结构
import { describe, expect, it, beforeEach, afterEach, vi } from "vitest";
// 导入要测试的模块(使用项目路径别名)
import { TargetClass, TargetFunction } from "@/module/target-module";
// 导入类型定义
import type { TargetType } from "@/module/target-module";
describe("测试描述", () => {
beforeEach(() => {
// 测试前的准备工作
});
afterEach(() => {
// 测试后的清理工作
vi.clearAllMocks();
});
describe("功能分组", () => {
it("应该正确处理基本场景", async () => {
// 基础功能测试
});
it("应该正确处理边界条件", async () => {
// 边界条件测试
});
it("应该正确处理错误情况", async () => {
// 错误处理测试
});
});
});
测试覆盖要求
基于 xiaozhi-client 项目覆盖率目标(80% 分支、函数、行、语句):
必须覆盖的场景
- 正常流程:所有主要功能路径
- 边界条件:最小值、最大值、空值、null/undefined
- 错误处理:所有异常分支和错误码
- 异步操作:Promise、async/await 的各种状态
测试数据设计
- 有效数据:符合预期的正常输入
- 无效数据:各种格式错误的输入
- 边界数据:临界值和极值
- 特殊数据:null、undefined、空字符串、空数组
测试执行命令
# 运行所有测试
pnpm test
# 运行特定测试文件
pnpm test src/server/{module}/{target}.test.ts
# 生成覆盖率报告
pnpm test:coverage
质量保证检查
pnpm typecheck # TypeScript类型检查
pnpm lint # 代码规范和格式检查
pnpm spellcheck # 拼写检查
pnpm check:all # 运行所有质量检查
测试最佳实践
测试命名
- 使用描述性的测试名称
- 采用中文描述
- 包含测试的具体场景和预期结果
测试结构
- 使用 AAA 模式:Arrange(准备)、Act(执行)、Assert(断言)
- 每个测试用例只验证一个行为
- 使用有意义的测试数据
Mock 使用
- 只 Mock 外部依赖,不测试实现细节
- Mock 行为应该真实且一致
- 在测试后清理 Mock 状态
Decide Fit First
Design Intent
How To Use It
Boundaries And Review