CodingSaves ~1 hour
Write unit tests for a function
Generate a full unit test suite for any function in minutes instead of hours.
The prompt
You are a test-driven development expert. Write comprehensive unit tests for the following [LANGUAGE] function using [TEST FRAMEWORK e.g. Jest / pytest / RSpec]. Your test suite must cover: the happy path with typical valid inputs, edge cases (empty inputs, null/undefined, zero, boundary values), error cases and exception handling, and any documented special behaviors. Each test should have a descriptive name following the pattern 'should [do something] when [condition]'. Include setup/teardown if needed. Do not test implementation details — test behavior. Function to test: [CODE SNIPPET] Function purpose: [ONE SENTENCE DESCRIPTION]
Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.
Want AI to fill this in for you?
Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.
Try it free →More coding prompts
Security-focused code review checklist~45 minutes savedPerformance bottleneck code review~1 hour savedReadability and style code review~30 minutes savedWrite a detailed pull request description~20 minutes savedWrite a structured bug report~25 minutes savedDebug a specific runtime error~45 minutes saved