跳到技能内容
词映 AI导航
发现工具选型指南Skills 技能AI 快讯AI图片AI视频AI文档AI办公AI助手AI搜索AI编程AI音频AI设计AI智能体模型与开发AI学习模型评测AI提示词内容检测AI金融AI 3D扫描与识别其他工具跨境电商 AI
词映 AI导航
工具库Skills 技能
我的收藏
词映 AI导航
发现工具选型指南Skills 技能AI 快讯AI图片AI视频AI文档AI办公AI助手AI搜索AI编程AI音频AI设计AI智能体模型与开发AI学习模型评测AI提示词内容检测AI金融AI 3D扫描与识别其他工具跨境电商 AI
Skills directory/Sweetteabittersugar/agency/unit-test-patterns

Write table-driven unit tests in Claude Code

Group normal, missing, and invalid inputs into one case table, then arrange, act, and assert independently.

中文

Install in Claude Code

A Claude Code workspace with Jest, pytest, or Go testing already set up. The example uses a pure label function.

  1. Review `.claude/skills/unit-test-patterns/SKILL.md` and its requirements at the pinned GitHub commit.
  2. Create `.claude/skills/unit-test-patterns/` in your project and save the reviewed file as `.claude/skills/unit-test-patterns/SKILL.md`.
  3. Start Claude Code from that project's root, then select `/unit-test-patterns` in the slash menu.

Example task

A rehearsal-label helper uses the case table `{cases:[[' Hall ','Hall'],['','Untitled'],[null,'Untitled']]}`. Trim surrounding spaces and return the default for an empty title or null. The cases share no mutable state.

What to check

The expected results are `['Hall','Untitled','Untitled']`. Arrange one table row per test, call the helper, and assert its output. Name scenarios so failures are easy to trace.

Original SKILL.md on GitHub · Updated 2026-11-14

Frequently asked question

How can I avoid copying tests for similar inputs?

Use one data table for names, inputs, and expected results. Reuse the test body for normal, boundary, and erroneous inputs and assert public outcomes.

Related skills from this repository

  • Design isolated browser regression scenarios in Claude Code
Browse Claude Code skills in the Chinese directory
词映 AI 导航Skills 技能
工具分类全部工具已本地化技能选型指南AI 快讯