agentsclimarketplace

Tdd

Skill ComeOnOliver/skillshub/skills/HoangNguyen0403/agent-skills-standard/tdd

🧠 The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.

Install
npx -y skills add ComeOnOliver/skillshub --skill tdd

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

Enforces Test-Driven Development (Red-Green-Refactor). Use when writing unit tests, implementing TDD, or improving test coverage for any feature.

SKILL.md

3.4 KB, as published. Nobody here has run it

Test-Driven Development (TDD)

Priority: P1 (OPERATIONAL)

The Iron Law

NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST. Code written before the test must be deleted. Start over.

The TDD Cycle

  1. RED: Write a minimal failing test. Verify failure (Expected error, not typo).
  2. GREEN: Write simplest code to pass. Verify pass.
  3. REFACTOR: Clean up code while staying green.

AAA Structure (Mandatory)

Every test must follow Arrange-Act-Assert:

  • Arrange: Set up inputs, stubs, mocks, and expected values.
  • Act: Call the single unit under test.
  • Assert: Verify output and side effects. One logical assertion per test. (See AAA Example for code structure).

Coverage Thresholds

  • Minimum: 80% (Statements, Functions, Lines), 75% (Branches).
  • Target: 90% (Statements, Functions, Lines), 85% (Branches).
  • Configure in test runner config (e.g. jest.config.ts, vitest.config.ts). Coverage below minimum is a build-gate failure.

Test Runner Commands

LanguageRunnerWatch ModeCoverage
TypeScript/JSjest / vitestvitest --watchvitest run --coverage
Gogo testgo test -v ./... -count=1go test -cover ./...
JavaJUnit 5 + Mavenmvn testmvn verify -P coverage
KotlinJUnit 5 + Kotest./gradlew test./gradlew jacocoTestReport
Dart/Flutterflutter testflutter test --watchflutter test --coverage

Core Principles

  • Watch it Fail: Prove the test works.
  • Minimalism: Don't add features/options beyond current test (YAGNI).
  • Real Over Mock: Prefer real dependencies unless slow/flaky.
  • One Reason to Fail: Test one behavior per test.
  • Descriptive Names: e.g. should_returnError_when_emailIsInvalid.

When to Use Mocks vs Real Dependencies

  • Database: Real DB (test container) or in-memory; mock as last resort.
  • HTTP/External APIs: Always mock.
  • Filesystem: Use temp dir; mock for unit isolation.
  • Time/Dates: Always mock/control.
  • Internal services: Real if fast (<200ms); mock if cross-network.

Verification Checklist

  • Every new function/method has a failing test first?
  • Failure message was expected?
  • Minimal code implemented passed?
  • AAA structure followed?
  • Coverage thresholds met?

Expert References

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.