Software Development · IT & Software

Write integration tests for an API

Write integration tests that cover my API's important behaviour, run in CI and do not break randomly. An expert, step-by-step prompt with inputs, method, deliverables, rules and a quality check.

Your prompt is ready 6 brackets to fill
You are a test automation engineer who writes reliable API test suites.
I work in IT & Software: a software company that ships a SaaS product. This work matters to engineering leads, developers and IT buyers.

## Goal
Write integration tests that cover my API's important behaviour, run in CI and do not break randomly.

## What matters in IT & Software
- Rules and standards that usually apply: data-protection law (GDPR in the EU, the DPDP Act 2023 in India, CCPA in California); SOC 2 or ISO 27001 security audits; OWASP secure-coding practice; open-source licence terms; the uptime and support promises in customer SLAs.
- Common risks to plan for: outages; data breaches and security holes; vendor lock-in; scope creep; knowledge held by one person; churn after a bad release.
- Tools commonly used: GitHub or GitLab; Jira; Slack; AWS, Azure or GCP; Datadog or Grafana; PostgreSQL or MySQL.
- Words people in this field use: SaaS; multi-tenant; SLA; incident; sprint; release; tech debt; API; ARR.
- Rules differ by country. If I have not said where I work, ask me, and do not present one country's law as if it applied everywhere.

## What I will give you
- API framework and language: [STACK]
- Endpoints to cover: [LIST OR PASTE ROUTES]
- How auth works: [AUTH METHOD]
- Database and external services: [DB, THIRD-PARTY APIS]
- Test tools we use or prefer: [e.g. Jest, Pytest, PHPUnit]
- Anything else you should know: [EXTRA CONTEXT, or "none"]

## How to work through it
1. Restate the technical problem, the constraints (language, framework, versions, runtime) and what "done" means. List what you need to see that I have not given you.
2. Map each endpoint to the behaviours worth testing: success, validation errors, auth failures, not found, conflicts and limits.
3. Set up a clean test database per run with fixtures or factories.
4. Stub or mock external services at the network edge.
5. Write the tests with clear names that read like specifications.
6. Add checks for response shape, status codes and side effects in the database.
7. Make tests independent so they can run in any order and in parallel.
8. List the edge cases, failure modes and security risks you considered, and how the solution handles each.
9. Explain how to verify the result: the exact commands, tests or checks to run, and what a pass looks like.

## What to deliver
- A test plan table: endpoint, case, expected result
- Test setup and teardown code
- The complete test files
- CI configuration to run them
- Notes on keeping the suite fast and stable

## Expert rules
- Write production-quality code: clear names, small functions, error handling, no placeholder comments such as "..." or TODO.
- Prefer the standard library and the tools already in my stack; justify any new dependency in one line.
- Never weaken security for convenience: validate input, use parameterised queries, keep secrets out of code.
- Respect uptime, security and data-protection requirements. If anything in my plan or inputs conflicts with them, say so plainly and suggest a fix.
- Do not invent facts, figures, laws, sources or quotes. Label anything you had to assume with "Assumption:" and tell me how to check it.

## Format
- Put each file in its own fenced code block, headed with its full path.
- Explain decisions in short bullets after the code, not as long paragraphs.
- If the answer is long, give a one-paragraph summary first.

## Before you answer
Check your draft against this list and fix anything that fails:
- The code works as written: no invented libraries, functions or APIs, and versions are named where they matter.
- Every item under "What to deliver" is complete, specific to my inputs and usable as it is, with no placeholders left for me to guess.
- Where it applies, it shows the likely effect on deployment frequency and uptime.

If something essential is missing, ask me up to 3 short questions first. Otherwise, start.
Open in ChatGPT Claude Perplexity

How to use this prompt

  1. Copy the prompt. Press Copy prompt and the full text goes to your clipboard.
  2. Fill the brackets. Use the form above, or replace [STACK], [LIST OR PASTE ROUTES], [AUTH METHOD], [DB, THIRD-PARTY APIS], [e.g. Jest, Pytest, PHPUnit], [EXTRA CONTEXT, or "none"] with your own details.
  3. Paste and send. Paste it into ChatGPT, Claude, Gemini and DeepSeek and send. Ask follow-up questions to refine the answer.

Why use this Write integration tests for an API prompt?

This write integration tests for an api prompt is written for a software company that ships a SaaS product. It tells the assistant who the answer is for (engineering leads, developers and IT buyers) and the limits it must respect: uptime, security and data-protection requirements. That context is what turns a generic reply into one an IT & Software team can use straight away.

Most people type a single line and get a generic answer back. This prompt gives the assistant the role, the context and the structure it needs, so the first answer is already close to what you would hand to your team. Because it is written for IT & Software, it keeps the focus on what that industry measures: deployment frequency and uptime.

How to get the best answer

  1. Be specific in the brackets: real names, numbers and dates give a far better answer than placeholders.
  2. Paste real material: where the prompt asks for notes, data or text, paste the actual content rather than a summary.
  3. Refine in the same chat: ask "make it shorter", "turn it into a table" or "add more detail on step 2".
  4. Check the result: review it against what you know about deployment frequency and uptime before you share it.

FAQ

Frequently asked questions

Which AI assistant works best with this Write integration tests for an API prompt?

It works in any chat assistant. It suits ChatGPT, Claude, Gemini and DeepSeek best. Paste it in, send it, and ask follow-up questions in the same chat.

What do I need to replace before sending it?

Replace the 6 highlighted brackets – [STACK], [LIST OR PASTE ROUTES], [AUTH METHOD], [DB, THIRD-PARTY APIS], [e.g. Jest, Pytest, PHPUnit], [EXTRA CONTEXT, or "none"] – with your own details. The more specific you are, the better the answer.

Is this prompt only for IT & Software?

This version is written for a software company that ships a SaaS product. The same prompt is also available for 0 other industries, listed on this page.

Is it free to use?

Yes. Copy it as often as you like and use it in your own work. No sign-up is needed.

Can I trust the answer?

Treat it as a strong first draft. Check facts and figures yourself, especially anything with legal, financial, medical or safety consequences.

Keep exploring

Browse more IT & Software prompts