write-unit-test
БесплатноБез исполняемых скриптовНе проверенWrite unit tests with it_should_ names, Arrange-Act-Assert, rstest cases and a stopped clock for time. Use when adding or reviewing unit tests.
от torrust★ 539 звёзд на GitHubОб этом скилле
Writing Unit Tests
Core Principles
Unit tests in this project are written against the Test Desiderata — the 12 properties that make tests valuable, defined by Kent Beck. Not every property applies equally to every test, but treat them as the standard to reason about and optimize for.
| Property | What it means |
|---|---|
| Isolated | Tests return the same result regardless of run order. No shared mutable state. |
| Composable | Different dimensions of variability can be tested separately and results combined. |
| Deterministic | Same inputs always produce the same result. No randomness, no wall-clock time. |
| Fast | Tests run in milliseconds. Unit tests must never block on I/O or sleep. |
| Writable | Writing the test should cost much less than writing the code it covers. |
| Readable | A reader can understand what behaviour is being tested and why, without context. |
| Behavioral | Tests are sensitive to changes in observable behaviour, not internal structure. |
| Structure-insensitive | Refactoring the implementation should not break tests that test the same behaviour. |
| Automated | Tests run without human intervention (cargo test). |
| Specific | When a test fails, the cause is immediately obvious from the failure message. |
| Predictive | Passing tests give genuine confidence the code is ready for production. |
| Inspiring | Passing the full suite inspires confidence to ship. |
Some properties support each other (automation makes tests faster). Some trade off against each other (more predictive tests tend to be slower). Use composability to resolve apparent conflicts.
Reference: https://testdesiderata.com/ and Kent Beck's original papers on Test Desiderata and Programmer Test Principles.
Coverage and Test-Gap Policy
The repository prefers high maintainable automated coverage.
Tracked test code is Rust. A temporary issue-local verification script is not a
test: it requires an issue-specification rationale explaining why it is better
than a maintained Rust automatic test and, when written in Python, why Rust is
unsuitable. Promote durable behavioral checks into Rust tests when practical.
Manual verification is separate real use of the finished artifact; record its
actual evidence in manual-verification-evidence.md as defined by
docs/testing.md.
When recording validation evidence in an issue specification or test-refactor
plan, name the toolchain or runtime that produced every command result when it
can affect behavior. For example, record cargo +nightly fmt --all -- --check
as nightly Rust toolchain; do not present cargo fmt --all -- --check as an
unqualified formatter result.
Practical priority order:
- Unit tests first (fast, deterministic, low maintenance)
- Integration tests where unit tests are insufficient
- End-to-end tests for cross-process/system validation
When behaviour is left untested, document why explicitly in one or more of:
- code comments near the boundary/constraint,
- issue spec notes,
- PR description.
Acceptable reasons to defer or avoid direct unit tests include:
- behaviour depends on out-of-process services not controlled by the test,
- deterministic unit tests would be disproportionately brittle,
- validation is better covered by integration/E2E tests with clear evidence.
If a feature is hard to test, treat that as design feedback first and improve testability when practical.
Coverage Attribution Is Unit-First
For package-owned behavior, treat unit-only coverage as the primary measurement and aggregate/global coverage as a separate broad-progress measurement. An aggregate report can include unit, integration, example, or end-to-end binaries; it cannot prove that a source seam has adequate unit protection. Record unit-only and integration-only measurements separately when coverage informs a test-boundary decision.
Do not reject a feasible focused unit test because an integration, example, or end-to-end test already executes the behavior. Decline a unit test only when it cannot protect the behavior at an appropriate boundary, or when a higher-level contract is demonstrably clearer and more maintainable; record that rationale in the issue-local evidence.
Inventory Behaviors and Choose the Test Level
Before writing or refactoring tests for a module
Установить write-unit-test в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл write-unit-test?
Write unit tests with it_should_ names, Arrange-Act-Assert, rstest cases and a stopped clock for time. Use when adding or reviewing unit tests.
Как установить скилл write-unit-test?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл write-unit-test запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic