How to use this prompt
- Paste the code and describe what it should do. Business rules make better tests.
- Pick your test framework and the kinds of cases to cover.
- Click Generate prompt, then Copy prompt or open it in ChatGPT, Claude, Gemini, Copilot, Perplexity, Grok or any AI app.
- Run the tests. If one fails, check whether the test or your code is wrong.
Testing tips
- Edge cases catch most bugs: empty input, zero, very large values and missing data.
- Run tests automatically on every change with your CI tool, such as GitHub Actions.
- Find risky code first with the Code Review & Security Check.
- Tests failing for an unclear reason? Use the Bug Finder & Fixer.
Example: how to fill it in
Here is how a developer might fill in the form for a pricing function.
| Field | Example answer |
|---|---|
| Language and framework | TypeScript |
| Test framework | Vitest |
| What it should do | Calculates the order total with a 10 percent discount over 100 dollars and adds tax |
| Dependencies | None |
| Cover | Normal cases, Edge cases, Boundary values |
| Experience | New to testing |
Common mistakes and how to fix them
- No expected behaviour. Say what the code should do, or the tests only copy current bugs.
- Testing internal details. Test results and behaviour, so refactors do not break tests.
- Skipping edge cases. Empty, zero and very large values find real bugs.
- Real API calls in unit tests. Mock external services to keep tests fast and reliable.
Follow-up prompts to try
After the first result, keep the same chat open and send one of these:
- "Add tests for invalid input."
- "Convert these tests to Pytest."
- "Write an integration test for the full checkout."
- "Explain mocking with this example."
Frequently asked questions
What is a unit test?
A small automated test that checks one piece of code works as expected.
Which frameworks does it support?
Jest, Vitest, Pytest, unittest, JUnit, PHPUnit, RSpec, Go testing and React Testing Library.
Will it find bugs?
Often. It flags behaviour that looks wrong while writing the tests.
I am new to testing. Can I use it?
Yes. Choose New to testing for simple explanations.
