Software Engineer skill · test-generator

Test generator

What it does

Generates unit tests for a function or module in your test framework, covering the happy path, edge cases and error cases, with a short note on what each test proves. Use it when adding tests to new or legacy code.

Time saved
~15–45 min per module (estimate)
Difficulty
Intermediate
Version
v1 · 2026-10-01

What you give it

  • Code under test (no secrets) — e.g. export function slugify(s: string) { return s.toLowerCase().trim().replace(/\s+/g, '-') }
  • Language and test framework — e.g. TypeScript + Vitest
  • Expected behaviour if not obvious (optional) — e.g. Should also drop punctuation

How it works

  1. Infer behaviour from code and the description; when they disagree, write the test for the described behaviour and flag it.
  2. Cover happy path, boundaries (empty, very long, unicode), invalid input and error handling.
  3. One behaviour per test, descriptive names.
  4. No network, clock or randomness without mocking.
  5. Don't test private implementation details.

Output

A test file in the given framework, then a table: Test · What it proves · Expected to fail today? (if behaviour and code disagree).

Quality checklist

  • ☑ Edge cases covered
  • ☑ Disagreements flagged
  • ☑ Deterministic tests

Human check: Run the tests and read them — a passing test that asserts the wrong thing is worse than none.

Example (fictional)
  • Code under test (no secrets): export function slugify(s) { return s.toLowerCase().trim().replace(/\s+/g, '-') }
  • Language and test framework: TypeScript + Vitest
  • Expected behaviour if not obvious: Should also drop punctuation
import { describe, it, expect } from "vitest";
import { slugify } from "./slugify";
describe("slugify", () => {
  it("lower-cases and hyphenates spaces", () => expect(slugify("Hello World")).toBe("hello-world"));
  it("drops punctuation", () => expect(slugify("Hi, there!")).toBe("hi-there"));
});
TestProvesFails today?
drops punctuationdescribed behaviourYes — code keeps punctuation

▶ Try it

Guests get 3 runs a day — sign in for more.Don't paste confidential or personal data.

Take it with you

Paste into any chat assistant and replace the {{placeholders}} with your details.

You are helping me with this task: Test generator.

## Instructions
1. Infer behaviour from code and the description; when they disagree, write the test for the described behaviour and flag it.
2. Cover happy path, boundaries (empty, very long, unicode), invalid input and error handling.
3. One behaviour per test, descriptive names.
4. No network, clock or randomness without mocking.
5. Don't test private implementation details.

## Output format
A test file in the given framework, then a table: **Test** · **What it proves** · **Expected to fail today?** (if behaviour and code disagree).

## Before you answer, check
- Edge cases covered
- Disagreements flagged
- Deterministic tests

If something important is missing from my inputs, say what you assumed. Never invent facts, numbers, names or quotes — mark anything you are unsure of as [to verify].

## My inputs
Code under test (no secrets):
{{code}}

Language and test framework:
{{framework}}

Expected behaviour if not obvious (optional):
{{behaviour}}

AI drafts, you decide. Skills help you start faster; check every fact, number and name before you use the output, and only paste data your company allows into AI tools. Time-saved figures are rough editorial estimates, not measurements.

Skills export in the open Agent Skills (SKILL.md) format. Spotted a problem? Post in the community.