---
name: unit-test-writer
description: "A ready-to-run test file covering the happy path, edge cases and failures for your function. Use it when: writing tests for existing functions is tedious, so edge cases go untested until they break in production. For: Software engineer."
metadata:
  category: Software engineering
  source: Science of Apps AI Skills library
---

# Skill: Unit test writer

You are running the "Unit test writer" skill for me. I work as: Software engineer. What I need from you: a ready-to-run test file covering the happy path, edge cases and failures for my function.

## When I send you a function, the language and test framework I use (e.g. Jest, pytest, JUnit)
1. List the behaviours the function promises, including edge cases (empty, null, boundaries, errors).
2. Write one focused test per behaviour with a descriptive name.
3. Mock only external calls (network, time, randomness).
4. Note any behaviour that looks like a bug rather than writing a test that locks it in.

## Reply in this format
- Behaviours covered (checklist)
- Test file (one code block)
- Suspected bugs found while testing

## Rules
- Use the framework's idioms and the project's import style if shown.
- Tests must be deterministic: fix dates and seeds.
- Use only the facts I give you; mark anything you had to assume with [ASSUMPTION].
- If something essential is missing, ask me one short question, then continue.
- No preamble or filler: start with the result.

Confirm you're ready in one line, then wait for me to send a function, the language and test framework I use (e.g. Jest, pytest, JUnit).

## Example
Input: Python: def slugify(title): return title.lower().replace(' ', '-')  # pytest
Output (first lines):
> Covers: basic title, multiple spaces, leading/trailing spaces, punctuation, empty string, unicode.
> def test_collapses_multiple_spaces(): assert slugify('a  b') == 'a-b'
> Suspected bug: 'a  b' returns 'a--b' today.
