Skip to content
Skills Library
Programming · Testing

tdd-practices

/tdd-practices

This skill should be used when writing a TDD plan, reviewing test quality, choosing between unit and integration tests, or applying red-green-refactor. Contains outside-in double-loop, test isolation, and test naming.

Repository
ai-plugins ↗
Licence
MIT
Last repository change
18.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 18.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

This skill should be used when writing a TDD plan, reviewing test quality, choosing between unit and integration tests, or applying red-green-refactor. Contains outside-in double-loop, test isolation, and test naming.

Original author description

This skill should be used when writing a TDD plan, reviewing test quality, choosing between unit and integration tests, or applying red-green-refactor. Contains outside-in double-loop, test isolation, and test naming.

How it works

  1. Red-Green-Refactor
  2. Outside-In Double-Loop (Onion/Hexagonal)
  3. What Makes a Good Test
  4. Test Isolation
  5. Integration vs Unit Tests
  6. Risk-Aware Test Depth
Original SKILL.md headings · 68 lines, 498 words
SKILL.md preview
---
name: tdd-practices
description: "This skill should be used when writing a TDD plan, reviewing test quality, choosing between unit and integration tests, or applying red-green-refactor. Contains outside-in double-loop, test isolation, and test naming."
---

# TDD Practices

## Red-Green-Refactor

The fundamental TDD cycle:

1. **RED** — Write a failing test that describes the behavior you want. Run it. Watch it fail. This confirms the test is actually testing something.
2. **GREEN** — Write the minimum code to make the test pass. No more. Resist the urge to build ahead.
3. **REFACTOR** — Clean up duplication, improve naming, extract patterns. Tests protect you from breaking anything.

Each cycle should take minutes, not hours. Small cycles build confidence and momentum.

## Outside-In Double-Loop (Onion/Hexagonal)

For architectures with clear layer boundaries:

**Outer loop:** Integration test at the boundary (HTTP request in, response out). Stays RED until all inner layers are wired.

**Inner loop:** Unit tests for each layer, working inward:
- Inbound adapter (controller/handler): test request parsing, response shaping
- Use case + domain: test business rules with mocked outbound ports. Domain is PURE — zero external dependencies.
- Outbound adapter (repo, gateway): test real integration (DB, API)
- Wire the composition root. Outer test goes GREEN.

Key insight: the mocks you write in domain tests define the contracts. Those contracts become port interfaces. Architecture emerges from the tests.

## What Makes a Good Test

**Test behavior, not implementation.** A good test survives a refactor. If you rename a private method and a test breaks, the test was testing implementation.

Good test: "When a user submits a valid order, the total reflects the discount."
Bad test: "The calculateDiscount private method returns 0.15 for orders over $100."

**Each test should have one reason to fail.** If a test can fail for three different reasons, it's three tests pretending to be one.

**Test names describe the scenario:**
- `rejects_expired_discount_codes`
- `applies_bulk_pricing_for_orders_over_ten_items`
- `returns_404_when_product_not_found`

## Test Isolation

Unit tests should not depend on:
- Database state
- File system
- Network calls
- Other tests running first
- System clock

Use test doubles (mocks, stubs, fakes) to isolate the unit under test. But don't mock what you don't own — wrap external dependencies in your own adapter and mock that.

## Integration vs Unit Tests

**Unit tests:** Fast, isolated, test one behavior. Run hundreds per second. Use for business logic, validation, data transformation.

**Integration tests:** Slower, test real connections. Use for database queries, API calls, file I/O, end-to-end user journeys.

**The split:** Most of your tests should be unit tests. Integration tests confirm the wiring works. A typical ratio: 80% unit, 20% integration.

**When to go integration-first:** If the feature is primarily about connecting things (CRUD endpoint, data pipeline, API gateway), start with an integration test. If the feature has complex business rules, start with unit tests for the rules.

## Risk-Aware Test Depth

- **Low risk:** Happy path + one or two edge cases. Basic error handling.
- **Moderate risk:** Happy path + edge cases + error scenarios. Boundary conditions.
- **High risk:** All of the above + failure modes + security checks + concurrent access + data integrity. Defensive tests that verify the system fails safely.

Versions

The database has no other skills named tdd-practices.

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

Downloads in the last 30 days: 0 · ranking

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

Similar skills

  • 100tdd-workflow
    TDD red-green-refactor workflow. Use when implementing a feature or bug fix test-first.
  • 100tdd
    Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
  • 90tdd-workflow
    Standardized Test-Driven Development (TDD) cycle (RED-GREEN-REFACTOR-VERIFY). Use when user asks to write tests, do TDD, implement test-first, or ensure code quality with high test coverage and regression prevention.
  • 90tdd-cycle
    Red-Green-Refactor TDD loop with mandatory false-positive check. Use when: test, TDD, red-green, failing test, write test first, test-driven.
  • 100tdd
    Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
  • 100tdd
    Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.

Feedback and reports

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