Skip to content
routebase
API Testing12 chapters

Chapter 01 of 12

Types of API Testing, and Where Each One Fits

Functional, contract, workflow, data-driven, performance, security and production tests, with what each one finds, what it misses, and where it belongs.

Most articles about the types of API testing read like a taxonomy exercise with no reader in mind. This one is organised around a more useful question. What class of defect does each method catch, and what will it happily let through.

If you only read one thing here, read the column that says what each method misses. Every method has such a gap, and those gaps are where production incidents come from.

The seven methods at a glance

MethodCatchesMissesTypical place
FunctionalWrong status, wrong values, missing headers, broken error pathsShape changes nobody asserted onPull request
ContractRenamed fields, changed types, dropped required propertiesValues that are wrong but well-formedPull request
WorkflowState that does not carry between calls, broken multi-step flowsAnything one call already provesPull request or nightly
Data-drivenEdge values, boundary conditions, per-input behaviourInteractions between separate callsPull request or nightly
PerformanceLatency regressions, error rate under concurrency, resource limitsCorrectness of any kindNightly or pre-release
SecurityAuthorization gaps, injection surfaces, misconfigurationBusiness-logic abuse a scanner cannot modelNightly, plus a light pass per pull request
Production monitoringReal outages, contract drift after deploy, stale dataAnything before the releaseContinuously

Functional tests

A functional test sends one request and asserts on the answer that comes back. It is the method everything else builds on, and it is also the one most likely to be done badly.

Done well, it asserts the status code, the two or three fields that carry the behaviour under test, and the response header that matters. Done badly, it either compares the whole body, which turns every unrelated change into a red run, or it asserts only that the status was 200, which passes while the payload degrades into nonsense.

Functional tests are also where negative cases live. An API that returns the right thing for good input and something undefined for bad input is only half tested, so the 400, the 401, the 403 and the 404 deserve cases of their own. Read more in functional tests.

Contract tests

A contract test validates the response against the specification instead of against an expectation written into the test. That single change moves the oracle outside the test, so a field that changed type fails without anyone touching the test file.

The method needs a specification to exist, and that is the one prerequisite the other methods do not have. In exchange it catches the entire class of defect that functional tests structurally cannot see, because a functional test only knows about the fields its author named.

Contract testing is often confused with integration testing, and the two answer different questions. Contract testing vs. integration testing works through the distinction and both sides of the consumer and provider relationship.

Workflow and scenario tests

Real APIs are used in sequences, and the sequence is where the interesting defects hide. A client registers, logs in, creates an order and then reads it back, and each step depends on something the previous step produced.

A workflow test chains those calls and passes values between them, so it catches the defects that only appear in combination. A resource is created but cannot be read back, a token is issued but not accepted, or an identifier changes format between the create response and the read path. None of those show up when each endpoint is tested on its own.

The cost is that workflow tests run slower and break more often than single-request tests, so use them for the flows that carry the business and not for everything you own. See workflow and scenario tests.

Data-driven tests

Some questions are about inputs, not about the endpoint. Whether a price field accepts zero, whether an email validator rejects the awkward cases, or whether a search behaves at its page-size boundary. All of these are the same request repeated with different values.

Writing one test per value produces a suite that nobody maintains. A data-driven run writes the case once and iterates over a table of rows instead, and the expected outcome can be a column too, so one case asserts different results for different inputs.

Running one case across a table of rows is the cheapest way there is to raise coverage of edge cases. The mechanics are covered under test data.

Performance tests

Performance testing answers a question correctness testing never asks. How does the API behave when many callers arrive at once. Three traffic profiles cover most of what a team needs to know.

ProfileWhat it doesWhat it answers
LoadSustained traffic at expected volumeDoes the service hold its latency budget on a normal day
StressTraffic raised until something givesWhere the ceiling is, and how the service fails when it gets there
SoakModerate traffic over a long periodWhether memory, connections or caches degrade over hours

The measurement that matters is the p95 and not the average, because the average hides the tail that users actually notice. A run that averages 120 ms with a p95 of 3 seconds is a bad run, and the average alone will not say so. See performance testing.

Security tests

Security testing overlaps with functional testing at one point only, namely the authorization check. Everything else it does is different in kind, because it probes for behaviour nobody intended instead of behaviour someone specified.

Automated scanning covers the mechanical categories well, and those categories are where most real breaches start. They are missing authorization on an object or a function, input handling that accepts what it should reject, misconfiguration, and information exposure. It cannot model your business rules, so a scanner will never notice that a refund endpoint lets a user refund somebody else's order if both users are legitimately allowed to call it.

That gap is why authorization deserves hand-written negative tests alongside the scanner. API security testing covers both halves.

Production monitoring

Every method above runs before or during a release, which means none of them watches the live service. Production monitoring is the only one that observes the thing your customers are actually using.

Production monitoring does two jobs at once, and most teams only collect the first. Synthetic checks answer whether the service is up and how fast it is responding, and contract validation on those same checks answers whether the deployed service still matches the contract it is supposed to serve. The second job is the one most teams skip, and it is the one that catches drift.

See testing in production for monitors, drift events and alerting that people do not learn to ignore.

Choosing what to build first

If you are starting from nothing, build in this order, because each step makes the next one cheaper.

  1. Functional tests for the happy path of every endpoint you own, generated from the specification where one exists.
  2. Contract validation on those same cases, which costs almost nothing once the cases exist.
  3. Negative cases for authorization and validation, because those are the failures that reach customers.
  4. Workflow tests for the two or three flows that carry your revenue.
  5. A CI gate, so all of the above runs without anyone remembering to.
  6. Monitoring and drift detection on the deployed environment.
  7. Performance and the full security profile on a schedule.

Teams that invert this order tend to end up with an impressive load-test setup and no idea at all when a field quietly changed type.

In Routebase

The methods above are not separate tools in Routebase. A test case is one HTTP request with declarative assertions, and the method is decided by what you do with that case.

A run from the history expanded into seven named results, four passed and three failed, each with a status code and a duration.
A finished run lists every case with its status, the status code the service returned and how long it took.

Link the case to a designed endpoint and it becomes a contract test, because a Schema Validation assertion checks the live response against the endpoint's documented schema. Add the case as a step in a scenario and it becomes part of a workflow, passing extracted values to later steps. Attach a data set to the suite and the same cases run once per row. Flip the runner from functional to performance mode and the same suite runs a load profile with iterations, threads and a per-case breakdown. Security scanning runs against the same environment through scan profiles, and monitors keep validating the deployed service afterwards.

One request, written once, serving whichever method you need. The Test Suites guide covers cases, assertions and run modes in detail.

Frequently asked questions

How many types of API testing are there?

Seven methods cover the practical ground. They are functional, contract, workflow, data-driven, performance, security and production monitoring. Longer lists usually split one of these into named variants, so load, stress and soak testing are three profiles of performance testing, not three separate methods. What matters is not the count but the coverage question, meaning whether every class of defect your API can produce has a method that would catch it.

What is the difference between functional and contract API testing?

A functional test carries its expectation inside the test, so it asserts that this endpoint returns this status and this value. A contract test validates the response against the published specification instead, so it fails when the shape of the answer changes even though nobody edited the test. Functional tests prove behaviour, contract tests prove the promise, and a serious suite runs both on the same request.

Which API tests should run on every pull request?

Run the fast, deterministic ones, meaning functional and contract tests against a preview or staging environment. They finish inside a normal review wait and they catch the regressions that are cheapest to fix before merge. Load tests, the full security profile and long soak runs belong on a nightly or weekly schedule, because a gate people wait ten minutes for is a gate somebody eventually switches off.

Last reviewed by The Routebase Team.

Ready to ship on it?

Routebase is live. Design your API once — docs, mocks, tests, and monitoring all follow from the same source.

14-day Pro trial — no credit card required.