unit-testing

unit-testing is a skill for Claude Code, Codex from williamzujkowski/standards. It costs 37 tokens per session (4,203 once invoked), scanned A, original, MIT.

A guide to unit testing, where small pieces of code are checked separately from databases, APIs, and other outside systems. It covers test-driven development (TDD), meaning writing a failing test before the code, followed by implementation and cleanup.

In plain words
What is it for?
Use it to write tests with pytest or Jest, structure them with arrange-act-assert steps, use mocks and fixtures, measure coverage, and run checks automatically in continuous integration.
Why use it?
It helps catch mistakes early with fast, repeatable tests and reduces dependence on external systems. It also provides patterns for organizing test data, replacing outside dependencies, and checking many inputs.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to write tests with pytest or Jest, structure them with arrange-act-assert steps, use mocks and fixtures, measure coverage, and run checks automatically in continuous integration.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/williamzujkowski/standards/unit-testing
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add williamzujkowski/standards --skill unit-testing
Clone the repo
git clone --depth 1 https://github.com/williamzujkowski/standards

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for unit-testing

README.md
[![agentmods](https://agentmods.dev/badge/skills/williamzujkowski/standards/unit-testing/github.svg)](https://agentmods.dev/skills/williamzujkowski/standards/unit-testing)
Your own site
<a href="https://agentmods.dev/skills/williamzujkowski/standards/unit-testing"><img src="https://agentmods.dev/badge/skills/williamzujkowski/standards/unit-testing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for unit-testing

Your own site · 80×15
<a href="https://agentmods.dev/skills/williamzujkowski/standards/unit-testing"><img src="https://agentmods.dev/badge/skills/williamzujkowski/standards/unit-testing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,203 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00037 $0.04203
Opus 5.5 $0.00015 $0.01681
Sonnet 5.5 $0.00007 $0.00841
Haiku 4.5 $0.00004 $0.00420

Measured yesterday against content hash 070b7896964e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-30, from the pricing page.

Security

Grade A, and why

unit-testing scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

The scan reads SKILL.md. This mod also ships 6 executable files (config/jest.config.js, resources/configs/jest.config.js, templates/example.test.js, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

@patch('requests.get')
skills/testing/unit-testing/SKILL.md · 631 lines

How it starts

The opening of the file, as written. The whole thing — 631 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Unit Testing Standards

Quick Navigation: Level 1: Quick Start (5 min) → Level 2: Implementation (30 min) → Level 3: Mastery (Extended)


Level 1: Quick Start (<2,000 tokens, 5 minutes)

Core Principles

  1. Test-Driven Development (TDD): Write tests before implementation (Red-Green-Refactor)
  2. Test Pyramid: 70% unit tests, 20% integration, 10% E2E
  3. Fast and Isolated: Tests run in milliseconds, no external dependencies
  4. Comprehensive Coverage: Aim for 80-90% code coverage minimum
  5. Clear and Maintainable: Tests serve as living documentation

Essential Checklist

  • TDD workflow: Write failing test → Implement → Refactor
  • Coverage targets: 80%+ overall, 95%+ for critical paths
  • Naming convention: test_<function>_<scenario>_<expected_result>
  • AAA pattern: Arrange, Act, Assert structure in every test
  • Mocking: Mock external dependencies (database, APIs, filesystem)
  • Fixtures: Reusable test data and setup/teardown
  • Parametrized tests: Test multiple inputs efficiently
  • CI integration: Tests run automatically on every commit

Quick Example

# pytest unit testing example
import pytest
from datetime import datetime

def calculate_discount(user_age: int, purchase_amount: float) -> float:
    """Calculate discount based on age and purchase amount."""
    if user_age < 18:
        return 0.0
    elif user_age >= 65:
        return purchase_amount * 0.15
    elif purchase_amount >= 100:
        return purchase_amount * 0.10
    return 0.0

# Unit tests following TDD
def test_calculate_discount_no_discount_for_minors():
    """Test that users under 18 receive no discount."""
    # Arrange
    user_age = 16
    purchase_amount = 100.0

    # Act
    discount = calculate_discount(user_age, purchase_amount)

    # Assert
    assert discount == 0.0

def test_calculate_discount_senior_discount():
    """Test that seniors (65+) receive 15% discount."""
    assert calculate_discount(65, 100.0) == 15.0
    assert calculate_discount(70, 200.0) == 30.0

def test_calculate_discount_large_purchase():
    """Test that purchases >= $100 receive 10% discount."""
    assert calculate_discount(30, 100.0) == 10.0
    assert calculate_discount(30, 150.0) == 15.0

@pytest.mark.parametrize("age,amount,expected", [
    (16, 100, 0.0),   # Minor
    (30, 50, 0.0),    # No discount
    (30, 100, 10.0),  # Large purchase
    (65, 50, 7.5),    # Senior
    (70, 200, 30.0),  # Senior large purchase
])
def test_calculate_discount_parametrized(age, amount, expected):
    """Test multiple discount scenarios."""
    assert calculate_discount(age, amount) == expected

Read the full file on GitHub · 631 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 631 lines · 37 tokens per session scan A 070b7896964e

Subscribe to this mod's changes

unit-testing is a skill published in the GitHub repository williamzujkowski/standards (18 stars, last pushed 1mo ago), licensed MIT. It adds 37 tokens to every session and 4,203 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-29.

Related

Other skills, from other repositories

rust-testing

Rust testing patterns including unit tests, integration tests, async testing, property-based testing, mocking, and coverage. Follows TDD methodology.

affaan-m/ECC · 31 tokens

cpp-testing

Use only when writing/updating/fixing C++ tests, configuring GoogleTest/CTest, diagnosing failing or flaky tests, or adding coverage/sanitizers.

affaan-m/ECC · 34 tokens

write-vibe-tests

Write or refactor Mistral Vibe tests with proper decoupling. Use when adding behavior coverage, testing ports/adapters, replacing brittle mocks, creating fakes, adding characterization tests before refactors, or changing tests under tests/ for vibe/core, vibe/cli, vibe/acp, tools, config, sessions, skills, hooks, MCP…

mistralai/mistral-vibe · 80 tokens

composing-matchers

Build compound Gomega assertions by combining matchers — And/SatisfyAll (all pass), Or/SatisfyAny (any pass), Not (negate), WithTransform to map the actual before matching, Satisfy for an ad-hoc predicate, HaveValue to dereference pointers/interfaces, HaveField for struct fields and method results, HaveEach for every…

onsi/gomega · 136 tokens

nw-test-organization-conventions

Test directory structure patterns by architecture style, language conventions, naming rules, and fixture placement. Decision tree for selecting test organization strategy.

nWave-ai/nWave · 33 tokens

spec-driven-tests

Rebuild a package's unit test suite around a behavior specification (SPEC.md) derived from the implementation, with every test citing a numbered rule ID. Use when asked to do a spec-driven test rebuild, write a SPEC.md for a package, repeat the state or store spec process (PRs.

tldraw/tldraw · 63 tokens