Skip to content
Skills Library
Programming · Testing

unit-test-design

/unit-test-design

Write unit tests that document behavior through explicit arrange-act-assert phases and a single assertion of intent. Use when writing or repairing a unit test that has grown hard to read.

Repository
AI-SKILLS ↗
Licence
MIT
Last repository change
05.09.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Write unit tests that document behavior through explicit arrange-act-assert phases and a single assertion of intent. Use when writing or repairing a unit test that has grown hard to read.

Original author description

Write unit tests that document behavior through explicit arrange-act-assert phases and a single assertion of intent. Use when writing or repairing a unit test that has grown hard to read.

How it works

  1. Method
  2. Litmus tests
  3. Boundaries
Original SKILL.md headings · 49 lines, 414 words
SKILL.md preview
---
name: unit-test-design
description: Write unit tests that document behavior through explicit arrange-act-assert phases and a single assertion of intent. Use when writing or repairing a unit test that has grown hard to read.
---

# Unit test design

A unit test is documentation that runs: it names a rule, shows the inputs
that trigger it, and pins the result so a change cannot pass unnoticed. When
one test sets up state between assertions, calls the system three times, or
checks six unrelated fields, a failure points nowhere and the reader learns
nothing. Shape each test so the behavior it guards is visible at a glance.

## Method

1. **Separate arrange, act, and assert with a blank line each.** Arrange
   constructs inputs and the object under test, act is the one call you are
   exercising, assert pins the outcome. If the three blocks do not stand
   apart on screen, the test is carrying more than one behavior.
2. **Make act a single invocation.** The behavior under test is one call:
   `total = invoice.total()`. Needing two calls to reach the assertion means
   you are testing a sequence, so name it that way or split it in two.
3. **Assert one intent, not one line.** A test called `applies_bulk_discount`
   checks the discount and nothing else. Compare a whole result object when
   the fields express the same claim, and move unrelated claims, the
   timestamp, the audit log, into their own tests.
4. **Keep computation out of the test.** Write the literal `42`, never
   `qty * price`. A test that recomputes the expected value with the same
   formula as the code passes whenever both share the same bug.
5. **Build inputs with named factories.** A helper such as
   `an_order(status="shipped")` states the field that matters and defaults
   the rest, so the one variable under test is not buried in a valid object.
6. **Cover the behavior's edges as separate cases.** For the rule at hand add
   empty, single, many, boundary, and the failure path with an explicit
   `assertRaises` or `expect().toThrow`, each as its own named test rather
   than one parametrized block that reports a single pass.

## Litmus tests

- From the test name and assert block alone, can you state the rule without
  reading the arrange phase?
- On failure, does the message name one broken behavior instead of diffing a
  twelve-field object?
- Could you delete the implementation and rebuild its spec from the test
  names and assertions?

## Boundaries

This governs the shape of one unit test, not what to test or at which layer:
defer scope to testing-strategy and names to test-naming. Where a project
fixes an assertion library or factory style, follow it over the exact forms
shown here.

Versions

RepositoryScoreLicence
This page · Amey-Thakur/AI-SKILLS90MIT
seyhunak/skilldeck100MIT

Database snapshot: 13.11.2026 · package version d255b8445897 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 86unit-test
    Writes isolated unit tests for a named file using Arrange-Act-Assert. Use when user requests unit tests, test coverage, or missing test cases for a file.
  • 100unit-testing-principles-aaa-pattern
    Use this skill when structuring clean, deterministic unit tests following Arrange-Act-Assert principles and strict assertion hygiene.
  • 100testing
    Design effective tests and decide what to test: unit vs integration, edge cases, the arrange-act-assert shape, and writing the minimal failing test for a bug. Use when users want tests for code, ask what cases to cover, want to improve coverage meaningfully, or practice TDD.…
  • 95tdd
    [UDS] Reference for Test-Driven Development: the Red-Green-Refactor cycle, FIRST principles, and Arrange-Act-Assert structure. Use when: writing a failing test before implementation, structuring a test with Arrange-Act-Assert, checking tests against FIRST. Not for: driving the…
  • 84tdd-assistant
    [UDS] 测试驱动开发(TDD)的参考资料:红-绿-重构循环、FIRST 原则与 Arrange-Act-Assert 结构。 Use when: 在实现前先写一个会失败的测试、用 Arrange-Act-Assert 组织测试、以 FIRST 检视既有测试。 Not for: 交互式地驱动 RED/GREEN 循环——该部分已移至采用层(XSPEC-095);测量测试覆盖了多少代码——请用 /coverage。 Keywords: TDD, test first, Red Green Refactor, FIRST, Arrange Act…
  • 100unit-test-writer
    Write focused unit tests for a function, class or module: one behaviour per test, Arrange-Act-Assert, descriptive names, boundary and error cases, no I/O, fast and deterministic; in the project's existing framework (pytest, JUnit 5, xUnit/NUnit, Jest/Vitest, PHPUnit, Go…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.