← Back to Skills Marketplace
287
Downloads
0
Stars
3
Active Installs
1
Versions
Install in OpenClaw
/install auto-test
Description
自动生成单元测试。分析代码逻辑,自动生成 pytest (Python)、JUnit (Java)、Jest (JavaScript) 等测试框架的测试用例。支持覆盖率报告生成。
README (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预览,避免覆盖现有测试
Usage Guidance
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.
Capability Analysis
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.
Capability Assessment
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.
How to Use
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install auto-test - After installation, invoke the skill by name or use
/auto-test - Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Auto-Test 1.0.0 - 初始版本发布
- 支持自动生成多语言(Python, Java, JavaScript/TypeScript, Go, Rust)主流测试框架的单元测试用例
- 集成覆盖率报告生成(pytest-cov, Jacoco, Istanbul 等)
- 自动识别函数/方法并生成边界条件和异常测试
- 命令行参数支持生成测试/报告、预览模式、排除目录等
- 输出可读性强的测试代码及测试说明
Metadata
Frequently Asked Questions
What is Auto Test?
自动生成单元测试。分析代码逻辑,自动生成 pytest (Python)、JUnit (Java)、Jest (JavaScript) 等测试框架的测试用例。支持覆盖率报告生成。 It is an AI Agent Skill for Claude Code / OpenClaw, with 287 downloads so far.
How do I install Auto Test?
Run "/install auto-test" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Auto Test free?
Yes, Auto Test is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Auto Test support?
Auto Test is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Auto Test?
It is built and maintained by zgbin (@zgbin); the current version is v1.0.0.
More Skills