# Testing Patterns

> 测试模式与原则。覆盖 Unit（单元测试）、Integration（集成测试）与 Mock（模拟）策略。

- **Type:** Skill
- **Install:** `agentstack add skill-misonl-ling-testing-patterns`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [MisonL](https://agentstack.voostack.com/s/misonl)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [MisonL](https://github.com/MisonL)
- **Source:** https://github.com/MisonL/Ling/tree/main/.agents/skills/testing-patterns
- **Website:** https://www.npmjs.com/package/@mison/ling

## Install

```sh
agentstack add skill-misonl-ling-testing-patterns
```

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

## About

# 测试模式

> 构建可靠测试体系的原则。

---

## 1. 测试金字塔

```
        /\          E2E（端到端，少量）
       /  \         关键流程
      /----\
     /      \       Integration（集成测试，中量）
    /--------\      API、数据库查询
   /          \
  /------------\    Unit（单元测试，大量）
                    函数、类等基础逻辑
```

---

## 2. AAA 模式

| 步骤 | 目的 |
|------|------|
| **Arrange（准备）** | 准备测试数据与上下文 |
| **Act（执行）** | 执行被测代码 |
| **Assert（断言）** | 断言结果是否符合预期 |

---

## 3. 测试类型选择

### 各类型使用时机

| 类型 | 适用场景 | 速度 |
|------|----------|------|
| **Unit（单元测试）** | 纯函数、核心逻辑 | 快（ **牢记：** 测试本身就是文档。如果别人无法通过测试理解代码行为，就应该重写测试。

## Source & license

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

- **Author:** [MisonL](https://github.com/MisonL)
- **Source:** [MisonL/Ling](https://github.com/MisonL/Ling)
- **License:** MIT
- **Homepage:** https://www.npmjs.com/package/@mison/ling

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-misonl-ling-testing-patterns
- Seller: https://agentstack.voostack.com/s/misonl
- 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%.
