Tdd

Use when implementing any feature or bugfix. Enforces RED-GREEN-REFACTOR cycle with test-first approach.

voidful 77edde1 1.2 KB Updated

File contents

Test-Driven Development (TDD)

The Iron Law

NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST

Write code before the test? Delete it. Start over.

The Cycle

  1. RED — Write a test that fails. Run it. Confirm it fails for the right reason.
  2. GREEN — Write the minimum code to make the test pass. Nothing more.
  3. REFACTOR — Clean up. Both test and production code. Tests must still pass.

In the Aixlarity Codebase

# Run a specific test
cargo test -p aixlarity-core test_name

# Run all tests
cargo test

# Run with output
cargo test -- --nocapture

What Counts as "Minimum Code"

  • If the test expects a return value, hardcode it first. Then generalize.
  • If the test expects an error, return the error. Do not add error handling for cases no test covers yet.
  • Resist the urge to "finish" the function. Let the next test drive the next behavior.

When to Skip (Ask the User First)

  • Throwaway prototypes that will be deleted within the session.
  • Generated code (e.g., provider adapter boilerplate).
  • Configuration files.

voidful/aixlarity/tree/main/.aixlarity/skills/tdd commit 77edde1657

Frequently asked questions

npx skillmds@latest add voidful/tdd