API Testing Senior cheat sheet: interview answers
Every question of this level with its correct answer and explanation, on one page for a quick review before the interview.
1. How should API tests be split across levels for a microservice?
Correct answer: Many unit and component tests, contracts between services, few E2E flows
Component tests run the service with stubbed dependencies and cover logic fast. Contracts guard integrations; a handful of E2E flows prove the whole system works.
2. What does Pact's
can-i-deploycheck answer?Correct answer: Whether this version is verified against the versions it talks to
The Pact Broker knows which consumer and provider versions verified each contract. The check blocks a deploy that would break a partner already in production.
3. What is the main risk of contract tests written by the provider team only?
Correct answer: They test what the provider thinks clients use, not what they use
Consumer-driven contracts capture real usage. Provider-only contracts often miss fields a client depends on, or test fields nobody uses.
4. Why review an API design before code is written?
Correct answer: Changing a published contract later is expensive for all clients
Spec-first reviews catch unclear errors, missing pagination or inconsistent naming when fixing them costs one edit, not a versioned migration.
5. How can API style rules be enforced across many teams?
Correct answer: Lint OpenAPI specs in CI against a shared rule set
Linters check naming, error formats, pagination and security schemes automatically, so reviews focus on the domain.
6. What is a sensible backward-compatibility policy for a public API?
Correct answer: Only additive changes in a version, breaking ones in a new version with a sunset
Clients need predictability. Tests guard the policy: contract checks fail on removed or retyped fields within a version.
7. Why are synthetic API checks in production useful even with a full test suite?
Correct answer: They detect outages and config issues that pre-release tests can't see
DNS, certificates, secrets, third-party outages and data issues appear only in the real environment. A scheduled check catches them before users do.
8. What is the difference between open and closed workload models in load testing?
Correct answer: Open sends at a set arrival rate; closed has fixed users waiting for replies
With a closed model, a slow server lowers the request rate and hides overload. An open model keeps sending, like real traffic, and shows queueing.
9. Why report p95 and p99 latency rather than averages in API load tests?
Correct answer: Averages hide the slow tail that many users still hit
A 100 ms average can hide 2-second p99s. In microservices, one request fans out to many calls, so tail latency adds up.
10. What is coordinated omission in load testing?
Correct answer: The tool waits for slow responses and under-reports latency
If the generator only sends the next request after a reply, slow periods produce fewer samples and look better than reality. Arrival-rate executors avoid it.
11. How should a load test define success?
Correct answer: SLO-style thresholds like p95 and error rate at a target load
Thresholds such as
p95 < 300 ms, errors < 0.1% at 500 RPSturn a load test into a pass/fail gate.12. What does a soak test reveal for an API that a short load test misses?
Correct answer: Memory leaks, connection exhaustion and growing queues
Some problems build up over hours: pools not releasing connections, caches growing without limit, logs filling disks.
13. What is BOLA, number one in the OWASP API Top 10 (2023)?
Correct answer: Broken object level authorization: accessing others' objects by ID
It's the most common API flaw. A test matrix of users × objects × operations is the systematic way to find it.
14. What does "broken object property level authorization" cover?
Correct answer: Reading or writing fields a user shouldn't, like
isAdminIt merges excessive data exposure and mass assignment: responses leaking fields and requests changing protected ones.
15. What is "unrestricted resource consumption" in API security?
Correct answer: Missing limits on size, rate, pages or costly operations
Huge page sizes, unbounded uploads, expensive searches or SMS sends without limits let attackers cause outages or bills.
16. How do you test for SSRF in an API that fetches a URL you provide?
Correct answer: Give internal addresses like
169.254.169.254and check they're blockedServer-side request forgery lets attackers reach internal services or cloud metadata. Allow-lists and blocking private ranges are the fix.
17. What is "unrestricted access to sensitive business flows"?
Correct answer: Bots automating flows like buying limited stock or fake sign-ups
The API works as designed but bots abuse it at scale. Tests look at rate limits, captchas, device checks and anomaly detection.
18. Why is "improper inventory management" an API risk?
Correct answer: Forgotten old or test endpoints stay exposed without fixes
Old
/v1or debug endpoints often skip new security checks. Testers compare deployed routes with the documented inventory.19. How should a service consuming third-party APIs be tested for safety?
Correct answer: Treat responses as untrusted: validate, limit, handle failures
Unsafe consumption of APIs is in the OWASP list. Stubs can return huge, malformed or malicious payloads to check validation.
20. How do you test an event-driven API that publishes to a message broker?
Correct answer: Consume the topic in tests and check payload, keys and schema
The HTTP call may succeed while the event is missing or malformed. Tests subscribe, wait with a timeout and assert the message.
21. What must consumers of at-least-once message delivery be tested for?
Correct answer: Handling duplicates idempotently
Brokers redeliver after failures. Processing the same "payment captured" event twice must not charge or ship twice.
22. Why test message ordering assumptions in async APIs?
Correct answer: Events can arrive out of order across partitions or retries
"Order shipped" may arrive before "order paid". Consumers need version checks or ordering keys, and tests should send events in odd orders.
23. What is a dead-letter queue and how is it tested?
Correct answer: Where failing messages go; test that poison messages land there
A malformed message shouldn't block a consumer forever. Tests send one and check it's moved aside with enough context to fix.
24. How do schema registries help test event contracts?
Correct answer: They reject schema changes that break compatibility rules
With backward compatibility enforced, a producer can't publish a schema that existing consumers can't read.
25. How do you test a saga that spans several services?
Correct answer: Check each step, compensations on failure and the final consistent state
Inject a failure in step three and confirm steps one and two are compensated, e.g. reservation released and payment refunded.
26. What is multi-tenant isolation testing?
Correct answer: Proving one tenant can never read or change another tenant's data
Tenant IDs from tokens, not request bodies, should scope every query. Tests try cross-tenant IDs on every endpoint, including exports and search.
27. How should a GDPR data deletion request be tested end to end?
Correct answer: Data is removed or anonymized in every service, cache and index
Personal data spreads to search indexes, analytics, logs and other services. Tests follow it everywhere the data map says it lives.
28. Why check API logs for personal data in tests?
Correct answer: Tokens and personal data in logs are a leak and a compliance risk
A test can call an endpoint with a known marker value and search the logs for it, catching unmasked emails or tokens.
29. What is the main challenge of using production traffic recordings for API tests?
Correct answer: Removing personal data and keeping recordings current
Recorded traffic is realistic but sensitive and ages fast. Anonymization and refresh jobs are part of the cost.
30. How can mocks of a dependency drift from reality, and how do you catch it?
Correct answer: The real API changes; verify mocks via contracts or scheduled runs
A stub saying
200while the real service now returns201hides integration bugs. Contract tests or scheduled checks against the real API keep stubs honest.31. What does property-based testing add to API test suites?
Correct answer: Many generated inputs checked against invariants
Invariants like "creating then reading returns the same data" or "no input causes a 500" find edge cases nobody listed.
32. What is the oracle problem in API testing, and a way around it?
Correct answer: Exact results are unknown; check invariants or compare with a reference
For complex calculations, compare with a previous version, a simpler implementation or relations between inputs (metamorphic testing).
33. How do you decide between Postman collections and code-based API tests for a team?
Correct answer: By who maintains them, review needs, reuse and CI integration
Collections suit exploration and shared manual checks. Long-lived regression suites usually live better in code with the service.
34. What are the limits of AI-generated API tests?
Correct answer: They may check what the code does, not what it should do
Generated tests can lock in bugs as expected behaviour. Humans must check expected results against requirements.
35. How can traces from observability tools improve API tests?
Correct answer: Asserting on internal calls, e.g. no N+1 queries or extra hops
Tests can read the trace of a request and check query counts or that a cache was hit, catching performance regressions early.
36. What should a quality gate for an API service check before deploy?
Correct answer: Green tests, verified contracts, no critical vulns, linted spec
Combining these checks catches broken logic, broken partners, security issues and inconsistent design before production.
37. How should API test runtime be managed as the suite grows?
Correct answer: Parallelize, isolate data, select by change and move checks down
Fast feedback keeps the suite useful. Isolated data enables parallel runs; tagging allows quick PR subsets and full nightly runs.
38. How do SLOs and error budgets guide API testing priorities?
Correct answer: Endpoints burning error budget get more testing and reliability work
If checkout misses its 99.9% target, effort shifts to its failure modes: timeouts, retries, dependency errors.
39. How should error responses be covered by contracts?
Correct answer: Contract the error format and codes clients rely on, not only success
Clients branch on
409or specific error codes. Changing them breaks clients as surely as changing a success field.40. What is a good strategy for testing a CDN or cache in front of an API?
Correct answer: Check cache keys,
Vary, private data and purge after updatesWrong cache keys can serve one user's data to another or ignore language headers. Tests send varied headers and check hits and misses.
41. How do you test that an API rate limiter works across several instances?
Correct answer: Spread requests across instances and check the shared limit holds
In-memory limiters per instance multiply the real limit by the instance count. Distributed limits need a shared store and tests that hit several nodes.
42. What should be tested for long-running operations exposed via API?
Correct answer: Polling, cancellation, timeouts, retries and the final result
Jobs can fail halfway, be cancelled or time out. Each state needs a clear status and safe cleanup.
43. What is the advantage of component tests that start one service with real DB in containers?
Correct answer: Realistic behaviour with fast, isolated runs and no shared staging
Testcontainers-style setups give each run its own database, so tests can be destructive and parallel.
44. How do you test GraphQL authorization properly?
Correct answer: Per field and per resolver, including nested paths
A user may be blocked from
user(id)but reach the same data viaorder { customer { email } }. Every path needs checks.45. Why test API responses with very large datasets?
Correct answer: Pagination, timeouts and memory can fail only at scale
An export that works with 100 rows may time out or run out of memory with a million. Tests with seeded volume catch it.
46. What is a safe way to test destructive endpoints in a shared environment?
Correct answer: Use isolated tenants or data created by the test itself
Deleting someone else's data breaks their tests. Isolation by tenant, prefix or ephemeral environment keeps it safe.
47. What should be tested when an API adds a new required request field?
Correct answer: It's a breaking change for clients; needs a new version or default
Old clients don't send it and start getting 400s. Contract tests with old consumer versions catch it before release.
48. How do you test webhook delivery at scale?
Correct answer: Retries with backoff, ordering, signatures, receiver downtime
When a receiver is down for an hour, events must queue and retry without flooding it on recovery, and duplicates must be safe.
49. What is the trade-off of testing against a shared staging environment?
Correct answer: Realistic integration, but data clashes, drift and blocked teams
Many teams use ephemeral environments and contract tests to reduce dependence on one fragile shared stage.
50. How should flaky API tests be measured and handled?
Correct answer: Track flake rate per test, quarantine with owners and fix causes
Flakes often reveal real race conditions in async processing. Data shows where to invest.
51. How can mutation testing evaluate an API test suite?
Correct answer: Change server logic slightly and see if any API test fails
If flipping a validation rule leaves all tests green, the suite doesn't check it. Mutation scores point to weak assertions.
52. What should a test strategy say about third-party API sandboxes?
Correct answer: Their limits and differences, plus stubs for what sandboxes can't do
Sandboxes may lack features, rate-limit tests or behave differently. Stubs cover rare errors; a production smoke confirms the real setup.
53. How do you test time-dependent API behaviour like token expiry deterministically?
Correct answer: Inject a controllable clock or short test-only lifetimes
Controlled time makes expiry, scheduling and daylight saving tests fast and repeatable.
54. Why include negative tests in API contract tests?
Correct answer: Clients rely on errors, like a 404 for missing items
If a provider changes "not found" from
404to200with null, consumers break. The contract should pin it down.55. What is API inventory testing in a large organization?
Correct answer: Comparing deployed endpoints with documented ones to find shadow APIs
Gateway logs or scans reveal undocumented endpoints, which often lack security reviews and tests.
56. How do you test that an API degrades gracefully when a non-critical dependency fails?
Correct answer: Fail it and check the core response still works with a fallback
A product page should still return when recommendations are down, maybe without that section. Fault injection proves it.
57. What makes chaos experiments on APIs safe?
Correct answer: A hypothesis, small blast radius, monitoring and a way to stop
Start in staging or a small slice of traffic, watch SLOs, and abort when metrics cross limits.
58. How should API tests handle feature flags?
Correct answer: Set flags per test or project and test both states of key flags
Flags change API behaviour too. Uncontrolled flags make tests flaky when someone toggles them in shared environments.
59. How do you test API localization, e.g. error messages in several languages?
Correct answer: Send
Accept-Languagevariants and check messages and formatsMessages, number and date formats may depend on the header. Codes should stay stable across languages for clients.
60. Why should API error codes, not messages, be what clients and tests rely on?
Correct answer: Messages change and get translated; codes stay stable
Tests asserting exact message text break on every wording change. Stable machine-readable codes like
ORDER_LIMIT_REACHEDdon't.61. How do you test that an API never returns data from a cache after a user's permissions change?
Correct answer: Revoke access, then request again and check denial, including via CDN
Cached authorization decisions or responses can keep exposing data. Tests change roles mid-session and check every layer.
62. What is the role of API tests in a zero-downtime deployment?
Correct answer: Checking old and new versions work side by side during rollout
During a rolling or blue-green deploy, both versions serve traffic and share the database. Tests cover mixed-version calls and migrations.
63. How do you test database migrations that change an API's data?
Correct answer: Run them on realistic data, check API reads and writes before and after
Expand-and-contract migrations keep old and new code working. API tests run against both phases.
64. What should be measured to know whether API testing is effective?
Correct answer: Escaped API defects, incidents by cause and time to detect
Outcome metrics show gaps. If most incidents come from config or dependencies, that's where tests should grow.
65. Why is it useful to version and review test data definitions like code?
Correct answer: Changes to shared fixtures can break many tests silently
Factories and seed files are shared dependencies. Reviewing them prevents surprises like a renamed default user.
66. How do you test that an API enforces limits on expensive operations, like exports?
Correct answer: Trigger many in parallel and check queues, limits and fair errors
Without limits, a few users can exhaust workers or databases. Tests check per-user caps and clear
429or queue responses.67. What is a safe practice for API tests that need real secrets in CI?
Correct answer: Inject them from a secret store with least privilege and rotation
Test accounts should have minimal rights, short-lived tokens and be separate from production credentials.
68. How do you approach testing an API with no documentation?
Correct answer: Explore it, record traffic, infer a spec and confirm with owners
Capturing real calls from clients gives a first map. Writing the inferred OpenAPI spec turns knowledge into a shared artifact.
69. What is the benefit of generating client SDKs from the OpenAPI spec in tests?
Correct answer: Typed clients expose mismatches between spec and server
If the server returns a field type the spec doesn't allow, typed clients or response validation fail loudly.
70. How should an API team handle a breaking change that slipped into production?
Correct answer: Roll back or restore compatibility, tell clients, add a test
The fix restores trust; the new test prevents a repeat. A blameless review asks why existing checks missed it.
71. What do you check when an API moves from one auth scheme to another?
Correct answer: Both schemes during migration, revocation of old tokens and scopes
Mixed periods are risky: old tokens may work too long, or scopes may map wrongly. Tests cover each transition step.
72. Why include API tests in incident post-mortems?
Correct answer: Each escaped bug should become a test at the right level
A regression test that reproduces the incident proves the fix and keeps the same failure from returning.
73. What is the main purpose of AsyncAPI for testers?
Correct answer: Describing message-driven APIs to build contracts and tests
Like OpenAPI for events: channels, message schemas and bindings. Tools validate messages and generate mocks from it.
74. What does a test for
X-Forwarded-Forspoofing check?Correct answer: That clients can't bypass IP-based limits by faking the header
If the API trusts any client-supplied
X-Forwarded-For, attackers rotate fake IPs to escape rate limits or allow-lists. Only trusted proxies should set it.75. How should breaking-change detection be automated for OpenAPI specs?
Correct answer: Diff the spec against the released one in CI and fail on breaking changes
Spec diff tools classify changes (removed field, new required parameter, changed type). Blocking them in CI turns the compatibility policy into a check.