← 返回 Skills 市场
287
总下载
0
收藏
3
当前安装
1
版本数
在 OpenClaw 中安装
/install auto-test
功能描述
自动生成单元测试。分析代码逻辑,自动生成 pytest (Python)、JUnit (Java)、Jest (JavaScript) 等测试框架的测试用例。支持覆盖率报告生成。
使用说明 (SKILL.md)
Auto-Test - 自动单元测试生成
智能自动生成单元测试,提升代码覆盖率,减少手动测试工作量。
核心功能
- 🧪 自动测试生成 - 分析函数/方法,生成对应测试用例
- 📊 覆盖率报告 - 集成 pytest-cov, Jacoco, Istanbul 等
- 🔄 多框架支持 - pytest, unittest, JUnit, Jest, Vitest
- 🎯 边界测试 - 自动生成边界条件、异常测试
- 📝 测试文档 - 生成测试说明和断言解释
使用场景
- 新功能开发后快速生成测试
- 遗留代码补充测试覆盖
- 重构前确保行为不变
- 代码审查时提供测试证据
快速开始
# 分析项目并生成测试
python3 scripts/generate-tests.py --path /path/to/project --framework pytest
# 生成覆盖率报告
python3 scripts/generate-tests.py --path . --coverage --output coverage.html
# 仅分析不生成(预览)
python3 scripts/generate-tests.py --path . --dry-run
配置选项
| 参数 | 说明 | 默认 |
|---|---|---|
--path |
项目路径 | . |
--framework |
测试框架 | pytest |
--coverage |
生成覆盖率 | false |
--output |
输出文件/目录 | ./tests/ |
--dry-run |
仅预览 | false |
--exclude |
排除目录 | node_modules,vendor,target |
支持的语言与框架
| 语言 | 框架 | 状态 |
|---|---|---|
| Python | pytest, unittest | ✅ 完整 |
| Java | JUnit 4/5, TestNG | ✅ 完整 |
| JavaScript/TypeScript | Jest, Vitest, Mocha | ✅ 完整 |
| Go | testing | ✅ 完整 |
| Rust | cargo test | ✅ 完整 |
| C# | NUnit, xUnit | 🚧 开发中 |
输出示例
# 生成的测试 (pytest)
def test_process_order_valid():
"""测试有效订单处理"""
order = Order(id=1, items=[...], total=100.0)
result = process_order(order)
assert result.status == "completed"
assert result.processed_at is not None
def test_process_order_invalid_total():
"""测试无效订单总金额"""
order = Order(id=2, items=[...], total=-10.0)
with pytest.raises(InvalidOrderError):
process_order(order)
def test_process_order_empty_items():
"""测试空购物车"""
order = Order(id=3, items=[], total=0.0)
with pytest.raises(EmptyCartError):
process_order(order)
工作流程
- 代码分析 - 解析 AST,识别函数、类、方法
- 逻辑提取 - 理解输入、输出、副作用、异常
- 测试生成 - 生成对应测试框架的测试代码
- 覆盖率计算 - 运行测试,生成覆盖率报告
- 结果输出 - 保存测试文件,提供总结
集成建议
- 结合
pre-commithook,提交前自动生成测试 - 与 CI/CD 集成,确保新代码有测试覆盖
- 使用
--dry-run预览,避免覆盖现有测试
安全使用建议
This skill is an instruction-only template for generating tests; it does not include the generator script or install anything. Before using it: (1) confirm you have a trusted test-generator (e.g., scripts/generate-tests.py) in your repo or install a known tool from a reputable source; (2) prefer --dry-run first to preview changes; (3) run generation and coverage in an isolated environment (container or CI) because running tests executes your project code and can have side effects or trigger network calls; (4) review generated tests and any files the tool will write before committing; (5) ensure required test tools (pytest, pytest-cov, Jacoco, Istanbul, etc.) are installed from trusted package sources. If the skill's source or the generator script is unavailable or untrusted, do not run the commands against production repositories.
功能分析
Type: OpenClaw Skill
Name: auto-test
Version: 1.0.0
The skill bundle describes a legitimate utility for automated unit test generation and coverage reporting across multiple programming languages. While the implementation script (scripts/generate-tests.py) mentioned in SKILL.md is missing from the provided files, the documentation contains no evidence of malicious intent, prompt injection, or suspicious external communication. The described behavior is entirely consistent with the stated purpose of the tool.
能力评估
Purpose & Capability
The name/description (automatically generate unit tests and coverage) match the SKILL.md instructions (analyze AST, generate tests, run coverage). One discrepancy: the skill references running python3 scripts/generate-tests.py, but no code or install is bundled — the SKILL.md therefore assumes the user/target repository or environment already provides the generator script or tooling.
Instruction Scope
The runtime instructions stay within the stated purpose: analyze code at the provided --path, generate test files, and optionally run coverage. They do not instruct uploading data to external endpoints or requesting unrelated credentials. Note: running tests/coverage means executing code from the target repository (side effects, network/database calls) which is expected for this task but a behavioral risk that the user must manage (use dry-run, sandboxing, or review before executing).
Install Mechanism
No install spec and no bundled code — lowest install risk. The SKILL.md is instruction-only. The missing installer/generator is a functional gap but not a covert install risk.
Credentials
The skill requests no environment variables or credentials, which is proportionate. However, it does require access to the project filesystem (--path) and will run code there; that access can expose repository secrets or cause side effects if tests execute destructive operations. The SKILL.md does not declare or restrict which files to read beyond --path.
Persistence & Privilege
always is false and the skill does not request persistent system-level privileges or modify other skills. It does suggest integrating with pre-commit/CI, which is typical integration guidance and not an automatic privilege change.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install auto-test - 安装完成后,直接呼叫该 Skill 的名称或使用
/auto-test触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Auto-Test 1.0.0 - 初始版本发布
- 支持自动生成多语言(Python, Java, JavaScript/TypeScript, Go, Rust)主流测试框架的单元测试用例
- 集成覆盖率报告生成(pytest-cov, Jacoco, Istanbul 等)
- 自动识别函数/方法并生成边界条件和异常测试
- 命令行参数支持生成测试/报告、预览模式、排除目录等
- 输出可读性强的测试代码及测试说明
元数据
常见问题
Auto Test 是什么?
自动生成单元测试。分析代码逻辑,自动生成 pytest (Python)、JUnit (Java)、Jest (JavaScript) 等测试框架的测试用例。支持覆盖率报告生成。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 287 次。
如何安装 Auto Test?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install auto-test」即可一键安装,无需额外配置。
Auto Test 是免费的吗?
是的,Auto Test 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Auto Test 支持哪些平台?
Auto Test 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Auto Test?
由 zgbin(@zgbin)开发并维护,当前版本 v1.0.0。
推荐 Skills