Agent skill · software engineering · jeremylongshore

generating-unit-tests

Test automatically generate comprehensive unit tests from source code

Why this skill is useful

Adds executable scripts for generating comprehensive unit tests across multiple languages and frameworks, which the AI cannot generate on its own.

What it needs

Requires go, jest, junit-jupiter, pytest, vitest installed locally. About 3k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.

What this skill does

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. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills jeremylongshore/generating-unit-tests

View the source on GitHub

Browse the @skills marketplace