🧪
QualityPython

Test Gen Expert

by val1813

Test Gen Expert is a Quality skill for Claude Code, published by val1813 in kwcode.

688 stars92 forkson val1813/kwcodeAdded 2026/08/12Repository updated 2026/05/14
Install in seconds
Install Test Gen Expert
Copy Test Gen Expert into your Claude Code skills folder. Run the command in your terminal, or review the source on GitHub before installing.
terminal
npx degit https://github.com/val1813/kwcode/tree/master/kaiwu/builtin_experts/testgen ~/.claude/skills/testgen

Requires Node.js. Downloads this skill only — not the rest of the repository — into your Claude Code skills folder.

Without Node.js

git clone https://github.com/val1813/kwcode.git

Clones the whole repository, then copy the skill’s own directory into your skills folder yourself.

In this catalog

Source file
kaiwu/builtin_experts/testgen/SKILL.md in val1813/kwcode
Installs to
~/.claude/skills/testgen
Collection
One of 19 skills cataloged from this repository
Category
Quality1354 skills

What Test Gen Expert does

Test Gen Expert helps write Python unit tests with AAA structure, clear naming, isolated fixtures, and correct mocking. Use it when generating or reviewing tests for normal, boundary, and error cases.

Test Gen Expert is cataloged under Quality on DirSkills.

Documentation

README

领域知识

你是单元测试专家。

AAA 模式

每个测试严格分为 Arrange(准备数据)→ Act(执行操作)→ Assert(验证结果)三段,用空行分隔。

命名规范

test_<被测函数><场景><期望结果>,例如 test_login_wrong_password_returns_401。

隔离性

每个测试独立运行,不依赖其他测试的执行顺序或副作用。 共享状态用 fixture(scope='function')重置。

Mock 策略

外部依赖(网络请求/文件系统/数据库/时间)必须 mock。 mock 的 patch 路径指向被测模块里的名字,非原始库路径。 例:被测函数 from requests import get → patch('mymodule.get')。

边界覆盖

每个函数至少测试:正常输入、空输入、边界值、异常输入。 批量场景用 @pytest.mark.parametrize。

断言精确

一个测试一个核心断言。异常测试用 pytest.raises。浮点比较用 pytest.approx。

常见坑

  1. mock 打错位置:必须 patch 被测模块里的名字
  2. 不 mock 时间/随机数:用 freezegun 或 mock.patch 固定
  3. 测试文件用相对路径读文件:改用 Path(file).parent 定位

经验规则(自动生成)

Frequently asked about Test Gen Expert

  • What else does val1813 publish alongside Test Gen Expert?

    Test Gen Expert is one of 19 skills that DirSkills catalogs from val1813/kwcode, the repository it ships in. Its siblings there include API Expert, Bug Fix Expert and DeepSeek API Expert. Each one is a separate skill with its own page in this directory, installs the same way Test Gen Expert does, and is maintained by val1813 in that same repository. The rest of the collection is listed on the val1813/kwcode page.

  • How does Test Gen Expert compare to other Quality skills?

    Test Gen Expert ranks #1054 by stars among the 1354 Quality skills in this catalog. The most-starred ones next to it are Benchmark, Benchmark Optimization Loop and API Design Patterns. DirSkills ranks by the star count of the repository each skill ships in, so that order reflects how popular those repositories are rather than any review of Test Gen Expert against them. Open each page to compare what they document and how they install.

More from val1813/kwcode

Test Gen Expert is one of 19 skills cataloged on DirSkills from val1813/kwcode.

See all 19 skills