write-test

Write regression-focused unit tests for uncovered code behaviors.

Updated Dec 21, 2018
One-click install
npx skills add https://github.com/dhnt/dhnt --skill write-test-dhnt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-test
Source: https://github.com/dhnt/dhnt/tree/main/catalog/md/test/write-test
Command: npx skills add https://github.com/dhnt/dhnt --skill write-test-dhnt

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you add meaningful test coverage when code lacks tests, so future changes don’t silently break behavior.

Core Features & Use Cases

  • Identify what to assert so each new test targets a real bug-risk (happy paths, boundaries, failure modes, and invariants).
  • Match existing conventions by inspecting nearby tests for naming, fixtures, and assertion style.
  • Build reliable tests using isolation (e.g., t.TempDir), minimal dependencies, and checks that fail when the code regresses.

Quick Start

Ask an AI to write a new test for the untested function or behavior in the specified module, making the test isolated, table-driven where appropriate, and framed to catch a realistic regression.

Frequently Asked Questions about write-test

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

FAQPage Schema
How do I write unit tests that prevent regressions for existing untested code?

To write unit tests that prevent regressions, target real uncovered behavior across common, boundary, and failure scenarios. Ensure tests are isolated, deterministic, and use minimal dependencies to fail reliably when code regresses.

What's the best way to structure table-driven tests for Go testing?

The best way to structure table-driven tests in Go testing is by inspecting nearby test conventions for naming and fixtures, then defining test cases that assert specific contract behaviors while keeping execution isolated and deterministic.

When do I need to add regression-focused tests to a function?

You need to add regression-focused tests when a function, contract, or behavior currently lacks coverage. Target real bug-risks by asserting happy paths, boundaries, failure modes, and invariants to prevent silent breaks.

How do I keep test isolation deterministic when adding new test coverage?

Keep test isolation deterministic by minimizing dependencies and utilizing built-in isolation tools like t.TempDir. Ensure checks remain independent so they reliably fail when the underlying code regresses.

Does this approach work for adding tests to functions with complex failure scenarios?

Yes, this approach works for complex failure scenarios by explicitly asserting invariants and boundary conditions. It frames the test to catch realistic regressions across common, boundary, and failure modes.

Why should I match existing test conventions when writing unit tests?

Matching existing test conventions ensures consistency by inspecting nearby tests for naming, fixtures, and assertion style. This minimizes friction and integrates the new regression-focused tests smoothly into the current codebase.