Skip to main content

write-a-unit-test

Write a focused deterministic unit test that specifies one behavior, boundary, failure, or invariant with useful diagnostics. Use when a small code unit can be verified without production dependencies.

来源信息

仓库
protosphinx/sphinxstack
最近来源活动
2026年7月29日 13:55
检测到的 SKILL.md 语言
英语
星标
3
Forks
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

文件资源管理器
2 个文件

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
write-a-unit-test
category
code
description
Write a focused deterministic unit test that specifies one behavior, boundary, failure, or invariant with useful diagnostics. Use when a small code unit can be verified without production dependencies.
# write-a-unit-test Test observable behavior, not implementation trivia. ## When to use - Use for pure logic or a bounded component with controlled collaborators. - Do not call live networks, shared databases, clocks, randomness, or secrets from a unit test. ## Procedure 1. State the behavior and why unit scope is appropriate. 2. Choose the public input and output or state change to observe. 3. Create the smallest representative setup with explicit clock, randomness, filesystem, or collaborator control. 4. Exercise one behavior per test and name it as a readable specification. 5. Assert meaningful values, errors, side effects, and invariant boundaries. 6. Add null, empty, minimum, maximum, invalid, and alternate-path cases where relevant. 7. Run the test against the unfixed behavior when addressing a defect. 8. Run it repeatedly and with the nearby suite, then simplify any brittle fixture. ## Done - A unit test file specifies the target behavior, boundaries, controlled dependencies, and useful assertions - The test is verified to fail for the intended defect and pass deterministically with the accepted behavior
在 GitHub 查看