# Code Test

> 当用户需要为生成的代码或改动代码时激活此技能。根据代码语言和项目上下文，生成单元测试、系统功能测试、系统压力测试和系统破坏性测试，确保测试覆盖全面且符合最佳实践。

- **Type:** Skill
- **Install:** `agentstack add skill-codyrao-agent-skills-code-test`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [codyrao](https://agentstack.voostack.com/s/codyrao)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [codyrao](https://github.com/codyrao)
- **Source:** https://github.com/codyrao/agent-skills/tree/main/code-test

## Install

```sh
agentstack add skill-codyrao-agent-skills-code-test
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Code Test - 代码测试生成

## 角色定位

作为专业的测试工程师和测试架构师，负责为代码生成全面的测试用例。

## 工作流程

### 1. 识别代码语言和类型

首先识别用户正在处理的代码语言和类型：
- **编程语言**：Go、Shell、JavaScript 等
- **代码类型**：函数、接口、API、消息队列等
- **测试类型**：单元测试、系统功能测试、系统压力测试、系统破坏性测试

### 2. 选择相应测试规范

根据代码语言选择对应的测试规范文件：

#### Go 语言测试
- **Go 代码测试**：使用 [references/go.md](references/go.md)

#### Shell 脚本测试
- **Shell 脚本测试**：使用 [references/shell.md](references/shell.md)

#### JavaScript 测试
- **JavaScript 代码测试**：使用 [references/js.md](references/js.md)

### 3. 生成测试用例

根据代码语言规范生成测试用例：

#### 单元测试
- 对于每次代码生成和代码改动，都需要按语言规范生成相关的单元测试用例
- 测试用例除了基本的功能测试参数，还要包括破坏性参数的传入传出
- 需要结合项目函数上下文

#### 系统功能测试
- 对于每次代码生成和代码改动，都需要按语言规范生成相关的系统自动化测试用例
- 系统测试要覆盖所有单元测试
- 对于网络 API、消息队列等网络中间件，要实现接口的功能测试

#### 系统压力测试
- 压力测试只针对外部网络 API 生成，如 HTTP、gRPC、NSQ 等外部接口
- 压力测试要支持多梯度，从而最大程度了解接口的性能

#### 系统破坏性测试
- 破坏性测试针对外部网络接口，测试异常情况下的系统表现
- 包括超时、断网、错误响应等场景

### 4. 输出测试用例

将生成的测试用例保存到项目相应位置：
- Go 语言：`*_test.go` 文件
- JavaScript：`*.{test,spec}.{js,ts}` 文件
- Shell：`*_test.sh` 文件

## 测试覆盖要求

### 单元测试覆盖
- 正常功能测试
- 边界条件测试
- 异常输入测试（根据项目上下文判断）
- 错误处理测试
- 并发安全测试（如适用）

### 系统功能测试覆盖
- API 接口功能测试
- 消息队列功能测试
- 数据库操作测试
- 文件操作测试
- 端到端流程测试

### 系统压力测试覆盖
- 不同并发级别下的性能表现
- 响应时间和吞吐量
- 资源使用情况

### 系统破坏性测试覆盖
- 网络异常（超时、断网）
- 服务异常（错误响应、服务不可用）
- 数据异常（非法数据、空数据）

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [codyrao](https://github.com/codyrao)
- **Source:** [codyrao/agent-skills](https://github.com/codyrao/agent-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-codyrao-agent-skills-code-test
- Seller: https://agentstack.voostack.com/s/codyrao
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
