Agent skill

Generating Unit Tests

by jeremylongshore in jeremylongshore/tons-of-skills-marketplace

Test automatically generate comprehensive unit tests from source code covering happy paths, edge cases, and error conditions.

MITAuto-check passedTesting & QA

Install Generating Unit Tests

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-unit-tests -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace generating-unit-tests --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/generating-unit-tests .claude/skills/generating-unit-tests && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
generating-unit-tests
GitHub stars
2.8k
Token cost
~1.4k tokens
SKILL.md length
491 words
Files
4 (incl. scripts, references, assets)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Test automatically generate comprehensive unit tests from source code covering happy paths, edge cases, and error conditions.

  • Works in 7 steps: Scan the codebase with Glob to locate… → Read each untested source file and extract → For each function, generate test cases… → …
  • Creating test coverage for functions
  • SKILL.md covers Overview, Prerequisites, Instructions and Output, plus 3 more sections
  • Calls npm and go

What it does

Generating Unit Tests is an agent skill from jeremylongshore/tons-of-skills-marketplace. Test automatically generate comprehensive unit tests from source code covering happy paths, edge cases, and error conditions. Use when creating test coverage for functions, classes, or modules. Trigger with phrases like "generate unit tests", "create tests for", or "add test coverage".

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including scripts, reference files and assets (for example `assets/README.md`, `references/README.md` and `scripts/README.md`). Compatibility notes: Designed for Claude Code

It sits in Testing & QA, covering Unit testing and Test coverage. It works with Jest and pytest. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • Creating test coverage for functions
  • With phrases like generate unit tests
  • Create tests for
  • Add test coverage

Example prompts

  • “generate unit tests”
  • “create tests for”
  • “add test coverage”
  • “/generating-unit-tests”

Requirements

  • Python 3
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Grep, Glob, Bash(test:unit-*)

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  1. Scan the codebase with Glob to locate source files that lack corresponding test files (e.g., src/utils/parser.ts without…
  2. Read each untested source file and extract
  3. For each function, generate test cases in these categories
  4. Create mock declarations for all external dependencies
  5. Write the test file following project conventions
  6. Run the generated tests to verify they pass, then check coverage to confirm the target function is fully exercised.
  7. Report coverage gaps and suggest additional test cases for uncovered branches.

What it can do on your machine

Read from SKILL.md and the folder at commit 80f86df. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Grep
    • Glob
    • Bash(test:unit-*)

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/, which the agent can run.

    Shell commands in SKILL.md call:

    • npm
    • go

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • jestjs.io
    • vitest.dev
    • docs.pytest.org
    • junit.org
    • pkg.go.dev

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Generating Unit Tests loads about 1.4k tokens when it runs, and up to ~1.4k if it reads all its reference files. Until then it costs about 77 tokens; SKILL.md has 491 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~77
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~1.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit 80f86df, republished under its MIT licence (© jeremylongshore). 491 words, ~1,428 tokens.

Download SKILL.mdSave it as .claude/skills/generating-unit-tests/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
generating-unit-tests
description
Test automatically generate comprehensive unit tests from source code covering happy paths, edge cases, and error conditions. Use when creating test coverage for functions, classes, or modules. Trigger with phrases like "generate unit tests", "create tests for", or "add test coverage".
allowed-tools
Read, Write, Edit, Grep, Glob, Bash(test:unit-*)
compatibility
Designed for Claude Code
version
1.21.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
tags
testing, unit-tests

Unit Test Generator

Overview

Automatically generate comprehensive unit tests from source code analysis covering happy paths, edge cases, boundary conditions, and error handling. Supports Jest, Vitest, Mocha (JavaScript/TypeScript), pytest (Python), JUnit 5 (Java), and Go testing with testify.

Prerequisites

  • Testing framework installed and configured (jest, vitest, pytest, junit-jupiter, or Go testing)
  • Source code with clear function signatures, type annotations, or JSDoc comments
  • Test directory structure established (__tests__/, tests/, spec/, or *_test.go)
  • Mocking library available (jest.mock, unittest.mock, Mockito, or gomock)
  • Package scripts configured to run tests (npm test, pytest, go test)

Instructions

  1. Scan the codebase with Glob to locate source files that lack corresponding test files (e.g., src/utils/parser.ts without __tests__/parser.test.ts).
  2. Read each untested source file and extract:
    • All exported functions and class methods with their signatures.
    • Parameter types, return types, and thrown exceptions.
    • External dependencies (imports from other modules, third-party libraries, I/O).
    • Pure vs. impure function classification.
  3. For each function, generate test cases in these categories:
    • Happy path: Valid inputs producing expected outputs (at least 2 cases).
    • Edge cases: Empty strings, empty arrays, zero, negative numbers, null, undefined, maximum values.
    • Error conditions: Invalid types, missing required fields, network failures, permission errors.
    • Boundary values: Off-by-one, integer overflow, string length limits.
  4. Create mock declarations for all external dependencies:
    • Database calls return predictable fixture data.
    • HTTP clients return canned responses with configurable status codes.
    • File system operations use in-memory buffers or temp directories.
  5. Write the test file following project conventions:
    • Match the existing test file naming pattern (*.test.ts, *.spec.js, test_*.py).
    • Group tests in describe/context blocks by function name.
    • Use beforeEach/afterEach for setup and teardown.
    • Include inline comments explaining non-obvious test rationale.
  6. Run the generated tests to verify they pass, then check coverage to confirm the target function is fully exercised.
  7. Report coverage gaps and suggest additional test cases for uncovered branches.
Show full SKILL.md (187 more words)Show less

Output

  • Test files placed alongside source files or in the project's test directory
  • Mock/stub files for external dependencies
  • Coverage report showing line, branch, and function coverage for tested modules
  • List of remaining coverage gaps with suggested test cases

Error Handling

ErrorCauseSolution
Cannot find module on importTest file path does not match project module resolutionCheck tsconfig.json paths and moduleNameMapper in Jest config
Mock not intercepting callsMock defined after module import caches the real implementationMove jest.mock() calls to the top of the file before any imports
Async test timeoutPromise never resolves due to missing await or unhandled rejectionAdd await before async calls; increase timeout with jest.setTimeout()
Tests pass alone but fail togetherShared mutable state leaking between testsReset state in afterEach; avoid module-level variables; use jest.isolateModules()
Snapshot mismatch on first runNo existing snapshot baselineRun with --updateSnapshot on first execution to create the baseline

Examples

Jest test for a string utility:

typescript
import { slugify } from '../src/utils/slugify';

describe('slugify', () => {
  it('converts spaces to hyphens', () => {
    expect(slugify('hello world')).toBe('hello-world');
  });
  it('lowercases all characters', () => {
    expect(slugify('Hello World')).toBe('hello-world');
  });
  it('removes special characters', () => {
    expect(slugify('hello@world!')).toBe('helloworld');
  });
  it('handles empty string', () => {
    expect(slugify('')).toBe('');
  });
  it('trims leading and trailing whitespace', () => {
    expect(slugify('  spaced  ')).toBe('spaced');
  });
});

pytest test for a data validator:

python
import pytest
from myapp.validators import validate_email

class TestValidateEmail:
    def test_accepts_valid_email(self):
        assert validate_email("user@example.com") is True

    def test_rejects_missing_at_sign(self):
        assert validate_email("userexample.com") is False

    def test_rejects_empty_string(self):
        assert validate_email("") is False

    def test_rejects_none(self):
        with pytest.raises(TypeError):
            validate_email(None)

Resources

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (scripts, references, assets) in skills/.curated/generating-unit-tests of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • assets/README.md
  • references/README.md
  • scripts/README.md

Open the folder on GitHubat commit 80f86df

Compare with similar skills

Generating Unit Tests next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Generating Unit Tests compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Generating Unit Tests this skilljeremylongshore/tons-of-skills-marketplace2.8k—~1.4kAutomated safety check: PassMIT
TDD Guidealirezarezvani/claude-skills28k—~3.4kAutomated safety check: PassMIT
TDD GuideLeoYeAI/openclaw-master-skills2.2k—~1.4kAutomated safety check: PassMIT
Unit Testingpetrkindlmann/qa-skills168—~3.9kAutomated safety check: PassMIT
Test DiscoveryEmeaAppGbb/spec2cloud100—~3.1kAutomated safety check: PassMIT
Generate Testscoco-research/coco503—~1.7kAutomated safety check: PassCustom licence

Similar skills

  • TDD Guide

    alirezarezvani/claude-skills

    Test-driven development skill for writing unit tests, generating test fixtures and mocks, analyzing coverage gaps, and guiding red-green-refactor workflows across Jest, Pytest, JUnit, Vitest, and…

    28k GitHub stars~3.4k tokensUpdated 1 mo ago
    Testing & QAAuto-check passed
  • TDD Guide

    LeoYeAI/openclaw-master-skills

    Test-driven development skill for writing unit tests, generating test fixtures and mocks, analyzing coverage gaps, and guiding red-green-refactor workflows across Jest, Pytest, JUnit, Vitest, and…

    2.2k GitHub stars~1.4k tokensUpdated 2 mo ago
    Testing & QAAuto-check passed
  • Unit Testing

    petrkindlmann/qa-skills

    Write effective unit tests with Jest, Vitest, or pytest. An agent skill from petrkindlmann/qa-skills.

    168 GitHub stars~3.9k tokensUpdated 4 mo ago
    Testing & QAAuto-check passed
  • Test Discovery

    EmeaAppGbb/spec2cloud

    Catalog existing tests — discover test frameworks, count tests by type, parse coverage reports, and map test-to-feature relationships.

    100 GitHub stars~3.1k tokensUpdated 5 mo ago
    Testing & QAAuto-check passed
  • Generate Tests

    coco-research/coco

    A skill your agent uses when asked to generate tests for a file, module or component, to raise coverage, or to bootstrap a suite for untested code.

    503 GitHub stars~1.7k tokensUpdated today
    Testing & QAAuto-check passed
  • Automatically updates regression tests based on interval analysis to maintain coverage of key program intervals.

    253 GitHub stars~2.7k tokensUpdated 1 mo ago
    Testing & QAAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Adapting Transfer Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill automates the adaptation of pre-trained machine learning models using transfer learning techniques.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Agent Context Loader

    jeremylongshore/tons-of-skills-marketplace

    Execute proactive auto-loading: automatically detects and loads agents.md files.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Aggregating Performance Metrics

    jeremylongshore/tons-of-skills-marketplace

    Aggregate and centralize performance metrics from applications, systems, databases, caches, and services.

    2.8k GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Analyzing Capacity Planning

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to analyze capacity requirements and plan for future growth.

    2.8k GitHub stars~947 tokensUpdated today
    Auto-check passed
  • Analyzing Database Indexes

    jeremylongshore/tons-of-skills-marketplace

    Process use when you need to work with database indexing. An agent skill from jeremylongshore/tons-of-skills-marketplace.

    2.8k GitHub stars~2k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Generating Unit Tests

What does Generating Unit Tests do?

Test automatically generate comprehensive unit tests from source code covering happy paths, edge cases, and error conditions. Generating Unit Tests is an agent skill from jeremylongshore/tons-of-skills-marketplace. Test automatically generate comprehensive unit tests from source code covering happy paths, edge cases, and error conditions.

When should I use Generating Unit Tests?

Generating Unit Tests fits situations like: creating test coverage for functions; with phrases like generate unit tests; create tests for; add test coverage.

How do I install Generating Unit Tests in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-unit-tests -a claude-code`. Or copy the skill folder (skills/.curated/generating-unit-tests in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/generating-unit-tests in your project. Claude Code loads it when a task matches its description.

How do I install Generating Unit Tests in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-unit-tests -a codex`. Or copy the skill folder (skills/.curated/generating-unit-tests in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/generating-unit-tests in your project. Codex loads it when a task matches its description.

Can I use Generating Unit Tests in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill generating-unit-tests -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/generating-unit-tests, .gemini/skills/generating-unit-tests, .github/skills/generating-unit-tests and .opencode/skills/generating-unit-tests in your project.

What does Generating Unit Tests need to run?

Going by SKILL.md and its folder, Generating Unit Tests needs the command-line tools its instructions call (npm and go). Our summary lists: Python 3. Its frontmatter pre-approves these tools: Read, Write, Edit, Grep, Glob, Bash(test:unit-*). Compatibility (from SKILL.md): Designed for Claude Code.

Does Generating Unit Tests access the network?

SKILL.md names 5 domains. As links in the text: jestjs.io, vitest.dev, docs.pytest.org, junit.org and pkg.go.dev. This is read from the text; nothing was executed.

Is Generating Unit Tests safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Generating Unit Tests use?

Generating Unit Tests is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Generating Unit Tests use?

About 1.4k tokens (SKILL.md is roughly 5.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 16 tokens, read only when the agent opens those files.

What are the alternatives to Generating Unit Tests?

Skills that share tags, products or a category with Generating Unit Tests: TDD Guide (alirezarezvani/claude-skills, 28k stars), TDD Guide (LeoYeAI/openclaw-master-skills, 2.2k stars), Unit Testing (petrkindlmann/qa-skills, 168 stars) and Test Discovery (EmeaAppGbb/spec2cloud, 100 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Generating Unit Tests?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,825 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 9, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.