Ling: Skill for Claude Code

.agents/skills/testing-patterns/SKILL.md

testing-patterns is a skill for Claude Code from MisonL/Ling. It costs 29 tokens per session (1,284 once invoked), scanned A, original, MIT.

A guide to testing patterns for unit tests, integration tests, end-to-end tests, and mocks. Unit tests check small pieces, while end-to-end tests check complete user flows.

In plain words
What is it for?
Use it to plan a testing strategy, structure tests with arrange-act-assert, test APIs and databases, and decide when to mock external systems.
Why use it?
It helps choose the right test scope and build tests that are fast, isolated, repeatable, and useful.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: installed under .agents/ (shared by several agents).

This is MisonL/Ling's own configuration. It tells Claude Code how to work on Ling itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything Ling configures →

Reuse

Borrowing it

Nothing to install: this file belongs to MisonL/Ling. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/MisonL/Ling/main/.agents/skills/testing-patterns/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/MisonL/Ling

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for testing-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/misonl/ling/testing-patterns.svg)](https://agentmods.dev/skills/misonl/ling/testing-patterns)
Your own site
<a href="https://agentmods.dev/skills/misonl/ling/testing-patterns"><img src="https://agentmods.dev/badge/skills/misonl/ling/testing-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 29 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,284 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00029 $0.01284
Opus 5 $0.00015 $0.00642
Sonnet 5 $0.00006 $0.00257
Haiku 4.5 $0.00003 $0.00128

Measured 3d ago against content hash a4720d9b4da5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

testing-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/test_runner.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/testing-patterns/SKILL.md · 179 lines

How it starts

The opening of the file, as written. The whole thing — 179 lines — stays where its author put it; the contents beside it link to each section on GitHub.

测试模式

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


1. 测试金字塔

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

2. AAA 模式

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

3. 测试类型选择

各类型使用时机

类型 适用场景 速度
Unit(单元测试) 纯函数、核心逻辑 快(<50ms)
Integration(集成测试) API、数据库、服务协作
E2E(端到端测试) 关键用户流程

4. 单元测试原则

优秀单元测试特征

原则 含义
Fast(快速) 单个用例 < 100ms
Isolated(隔离) 不依赖外部系统
Repeatable(可重复) 每次结果一致
Self-checking(自校验) 无需手工验证
Timely(及时) 与代码同步编写

单元测试该测什么

应该测试 不应测试
业务逻辑 框架内部实现
边界条件 第三方库本身
错误处理 过于简单的 getter(取值器)

5. 集成测试原则

重点覆盖

领域 关注点
API 端点 请求/响应链路
数据库 查询与事务行为
外部服务 契约一致性

Setup/Teardown(准备/清理)约定

阶段 动作
Before All(全局前置) 建立资源连接
Before Each(用例前置) 重置状态
After Each(用例清理) 执行清理
After All(全局清理) 释放连接

6. Mock(模拟)原则

何时需要 Mock

应该 Mock 不应 Mock
外部 API 被测代码本身
数据库(单元测试) 简单依赖对象
时间/随机数 纯函数
网络请求 内存型替代实现

Mock 类型

类型 用途
Stub(桩) 返回固定值
Spy(监视) 跟踪调用行为
Mock(模拟) 预设期望并校验
Fake(伪实现) 提供简化实现

7. 测试组织方式

命名规范

模式 示例
Should(行为式) "should return error when..."
When(条件式) "when user not found..."
Given-When-Then(前提-条件-结果) "given X, when Y, then Z"

分组方式

层级 用途
describe(分组) 归类相关测试
it/test(用例) 单个测试用例
beforeEach(前置) 共享初始化逻辑

8. 测试数据策略

常见策略

方法 用途
Factories(工厂) 动态生成测试数据
Fixtures(夹具) 预定义数据集
Builders(构建器) 链式构建对象

基本原则

  • 使用贴近真实的数据
  • 非关键字段可随机化(faker 数据生成库)
  • 共享公共 fixtures(预置数据)
  • 保持最小必要数据集

Read the full file on GitHub · 179 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 179 lines · 29 tokens per session scan A a4720d9b4da5

Subscribe to this mod's changes

testing-patterns is a skill published in the GitHub repository MisonL/Ling (8 stars, last pushed 5mo ago), licensed MIT. It adds 29 tokens to every session and 1,284 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

axiom-testing

Use when writing ANY test, debugging flaky tests, making tests faster, or choosing Swift Testing vs XCTest. Covers unit tests, UI tests, async testing, test architecture.

CharlesWiltgen/Axiom · 38 tokens

designing-tests

Designs and implements testing strategies for any codebase. Use when adding tests, improving coverage, setting up testing infrastructure, debugging test failures, or when asked about unit tests, integration tests, or E2E testing.

CloudAI-X/claude-workflow-v2 · 48 tokens

test-automation

Execute Vitest and Playwright test suites with result collection and failure analysis.

a5c-ai/babysitter · 0 tokens

testing-blocks

Use this when you have made AEM Edge Delivery Services code changes to blocks, scripts, or styles and need to validate them before opening a pull request. Covers unit testing for utilities and logic, browser testing with Playwright, linting, and guidance on what to test and how.

adobe/skills · 61 tokens

prd-auto-test-loop

A testing workflow driven by a product requirements document (PRD), which describes what a software version should do. It turns acceptance criteria into unit, integration, and end-to-end tests, then records the plan and results.

yunshu0909/yunshu_skillshub · 79 tokens

test-automation-expert

Comprehensive test automation specialist covering unit, integration, and E2E testing strategies. Expert in Jest, Vitest, Playwright, Cypress, pytest, and modern testing frameworks. Guides test pyramid design, coverage optimization, flaky test detection, and CI/CD integration. Activate on 'test strategy', 'unit tests'…

curiositech/some_claude_skills · 133 tokens