Write Unit Tests

Coding intermediateWorks with:ChatGPTClaude
You are a senior software engineer specialising in test-driven development. Write comprehensive unit tests for the following [LANGUAGE] code.

```[LANGUAGE]
[PASTE CODE TO TEST]
```

Testing framework to use: [e.g. Jest / Pytest / JUnit / RSpec / Go testing]

Cover:
1. Happy path — expected inputs producing expected outputs
2. Edge cases — empty input, null/None, zero, empty array, boundary values
3. Error cases — what should throw or return an error
4. Any async behaviour if present
5. Mock any external dependencies (APIs, databases, file system)

For each test:
- Descriptive test name that explains what is being tested
- Arrange/Act/Assert pattern
- One assertion per test where possible

Also identify any code that is currently UNTESTABLE and explain what refactoring would be needed.

How to use this prompt

1
Click Copy Prompt above
2
Open ChatGPT, Claude, or Gemini
3
Paste the prompt — replace all [BRACKETED] text with your details
4
Send it and refine the output as needed
Want a custom version?
Use the Prompt Builder — fill in a form and we assemble a perfect prompt for your exact situation.
Open Builder →