Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问clear审计通过

test-driven-development测试驱动开发

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

474

周安装

19

GitHub Stars

公开资料未说明

下载量

154
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:test-driven-development(测试驱动开发)
来源仓库:https://github.com/carvalab/k-skills
仓库路径:skills/test-driven-development
安装命令:
npx skills add https://github.com/carvalab/k-skills --skill test-driven-development
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/carvalab/k-skills --skill test-driven-development

简介

test-driven-development 倡导先写测试再实现功能的开发模式。

  • 以测试作为规格说明,确保需求理解准确。
  • 支持 Go 与 Node.js 项目的测试命令与监控模式。
  • 需配合 kavak 内部测试模式与 STS 模拟工具使用。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Test-Driven Development

Write tests before code. The test is the specification. If you can't write a test, you don't understand the requirement.

Related Skills: - kavak-documentation - Query for Kavak-specific testing patterns, kbroker event testing, STS mocking - Use kavak-platform/platform_docs_search MCP tool for testing best practices at Kavak

Quick Start

# 1. Write failing test first
# 2. Run to see it fail (RED)
# 3. Write minimal code to pass (GREEN)
# 4. Refactor while tests pass (REFACTOR)
# 5. Repeat

Test commands by language:

LanguageRun TestsWatch Mode
Gogo test./...go test./... -v
Node/TSnpm testnpm test -- --watch
Pythonpytestpytest-watch
Java./mvnw test./mvnw test -Dtest=*

The Red-Green-Refactor Cycle

1. RED: Write Failing Test

- Write ONE test for the next piece of behavior
- Test must fail for the RIGHT reason
- Use descriptive names: should_calculate_total_with_tax
- Follow Arrange-Act-Assert structure

2. GREEN: Make It Pass

- Write MINIMAL code to pass the test
- Don't optimize, don't refactor, don't add features
- "Fake it till you make it" is valid
- The goal is GREEN, not perfect

3. REFACTOR: Improve Design

- Clean up code while tests stay green
- Remove duplication
- Improve names
- Extract methods/functions
- Run tests after EVERY change

Common Rationalizations (Resist Them)

RationalizationCounter
"Let me just write one more method"Stop. Test what exists first
"I'll add tests after"You won't. Tests written after verify nothing
"It's too simple to test"Simple now, complex later. Test it
"I'll refactor tests later"Refactor production code, not test structure
"This is just scaffolding"Scaffolding becomes foundation. Test it

Anti-Patterns (What NOT to Do)

Anti-PatternProblemFix
The LiarTest passes but tests nothingAssert actual behavior
The MockeryOver-mocking hides real bugsMock boundaries only
Excessive Setup50 lines setup, 2 lines testSimplify SUT or use builders
The Slow PokeTests take minutesIsolate, mock I/O
The Local HeroPasses locally, fails in CINo env dependencies
Test-per-Method1:1 test-to-methodTest behaviors, not methods

Verification Checklist

Before committing, verify your tests:

[ ] Test fails when behavior is removed?
[ ] Test name describes the behavior?
[ ] Arrange-Act-Assert structure clear?
[ ] No test-only code in production?
[ ] Mocks verify behavior, not implementation?
[ ] Edge cases covered?

When TDD Is Mandatory

  • New features (write test first)
  • Bug fixes (write failing test that reproduces bug)
  • Refactoring (tests protect behavior)
  • API changes (contract tests first)

When to Adapt TDD

  • Exploratory/spike work (delete code after, then TDD)
  • UI prototyping (test logic, not layout)
  • Legacy code (add tests before changing)

Test Naming Convention

should_[expected_behavior]_when_[condition]

Examples:
- should_return_zero_when_cart_is_empty
- should_throw_error_when_user_not_found
- should_apply_discount_when_coupon_valid

References

ReferencePurpose
references/red-green-refactor.mdDetailed cycle walkthrough
references/anti-patterns.mdFull anti-pattern catalog
references/examples-go.mdGo TDD examples
references/examples-node.mdNode/TypeScript TDD examples
references/examples-python.mdPython TDD examples
references/examples-java.mdJava TDD examples
references/verification-checklist.mdPre-commit verification
references/testing-boundaries.mdWhat to mock, what not to mock

Best Practices

  1. One assertion per test - Multiple assertions hide failures
  2. Test behavior, not implementation - Tests survive refactoring
  3. Isolated tests - No shared state between tests
  4. Fast tests - Under 100ms per unit test
  5. Deterministic - Same result every run
  6. Self-documenting - Test name = specification

Principle: If you can't write a test for it, you don't understand what it should do. The test IS the specification.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

27.1%
按下载量换算42

trae

21.57%
按下载量换算33

Antigravity

16.92%
按下载量换算26

Codex

12.44%
按下载量换算19

windsurf

7.96%
按下载量换算12

Gemini CLI

3.78%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills