unit-testing

Design deterministic unit tests for business rules, boundaries, and error handling.

4|Updated May 16, 2026
One-click install
npx skills add https://github.com/machenjie/rd-skills --skill unit-testing-machenjie
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unit-testing
Source: https://github.com/machenjie/rd-skills/tree/main/src/foundation/capabilities/unit-testing
Command: npx skills add https://github.com/machenjie/rd-skills --skill unit-testing-machenjie

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It helps teams prevent regressions by ensuring business rules, boundaries, and error paths are validated with deterministic unit tests instead of fragile, implementation-anchored checks.

Core Features & Use Cases

  • Behavior-first test design: verifies observable outcomes (returned values, state changes, thrown errors, emitted events) rather than private call graphs.
  • Boundary and negative coverage: systematically covers edge cases, invalid inputs, and error paths for each non-trivial rule.
  • Deterministic, isolated execution: avoids shared mutable state, timing, randomness, and order-dependent behavior to keep tests trustworthy.
  • Rule-matrix testing: uses table-driven/parameterized tests to cover tiered logic and input/output matrices clearly.

Quick Start

Use this capability to generate unit tests for the business-rule logic you are changing by validating success cases, boundary values, invalid inputs, and error paths with deterministic inputs.

Frequently Asked Questions about unit-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write unit tests that validate business rules without coupling to implementation details?

To write unit tests that validate business rules without implementation coupling, assert observable outcomes like returned values, state changes, and thrown errors. Behavior-first test design verifies domain logic functions by checking public results rather than private internal call graphs.

What is the best way to cover boundary values and error paths in deterministic tests?

Boundary values and error paths in deterministic tests are covered by systematically targeting edge cases and invalid inputs. This approach ensures tests remain isolated, avoiding shared mutable state, timing, randomness, and order-dependent behavior to keep validation trustworthy.

How do I use parameterized testing for input and output matrices?

Parameterized testing handles input and output matrices using table-driven tests to cover tiered logic clearly. This rule-matrix testing method validates multiple input scenarios against expected outputs, ensuring comprehensive coverage for domain logic functions and state transitions.

When should I use table-driven tests for domain logic and state transitions?

Table-driven tests should be used for domain logic and state transitions when validating complex input/output matrices. They provide clear, deterministic isolation and behavioral assertions, making it easier to verify validators, transformers, and parsers across diverse input scenarios.

Does this approach work for testing local error handling where external dependencies are required?

No, this approach does not work when external dependencies are required. It is specifically designed for deterministic isolation targeting local error handling, algorithms, and parsers/formatters where external dependencies are absent, ensuring tests remain fast and trustworthy.

Why does my unit test fail when checking private call graphs instead of observable outcomes?

Unit tests fail when anchored to private call graphs because they create fragile, implementation-coupled checks. Behavior-first test design prevents regressions by validating observable outcomes like emitted events and thrown errors, ensuring tests survive internal refactoring.