AV
HomeAboutProjectBlog

© 2026 Ave syah Shina. All rights reserved.

  1. Home
  2. Blog
  3. 07 — Backend & API Automation — Testing the Contract

07 — Backend & API Automation — Testing the Contract

August 13, 20268 min read
Download as Markdown

"Just firing requests at endpoints and checking the status code" was my API-automation model, and it missed the thing being tested. The split that fixed it: backend testing checks the server side — the application and database layers, free from database defects like deadlock, corruption, or data loss — while API testing specifically verifies the contract the server exposes to its clients [1]. The contract is the thing. Every API test is an assertion that "when you send X, the server returns Y, with these side effects," and the whole discipline is about making that contract executable, repeatable, and runnable in CI.

The framing that landed for me is that the tools divide cleanly by who writes the tests and in what language. Karate writes tests in a business-readable Gherkin-like syntax, so a non-developer can author them. REST Assured is a Java library, so it lives inside the developer's codebase. Postman is a GUI first, so it suits collaborative authoring and exploration. The choice isn't "which is best" — it's "whose hands should the API tests be in."

What backend and API testing actually verify

The roadmap is precise about scope. Backend testing aims at the application layer and database layer, ensuring the system is free of database-specific defects — deadlocks, data corruption, data loss [1]. API testing (the more common modern framing) treats each endpoint as a contract: given a request that matches the spec, the response must match the spec, the status code must be correct, the schema must validate, and the side effects (a row written, an email queued, a cache invalidated) must have occurred.

The contract has several dimensions, and a thorough API test suite covers each:

  • Status correctness — 200 for a valid request, 404 for a missing resource, 401 for no auth, 422 for invalid input.
  • Schema and shape — the response JSON has the fields the contract promises, with the right types.
  • Data correctness — the values are right, not just the shape. Asking for user 42 returns user 42's data, not user 43's.
  • Side effects — a POST /users actually creates the row; a DELETE actually removes it.
  • Error behavior — invalid input produces a sensible error, not a 500 with a stack trace.

The failure mode I've hit most is teams testing only the first dimension (status codes) and calling it API testing. A suite of expect(200) assertions catches almost nothing of interest — the contract is in the data and the side effects.

The tools, by who they're for

Karate Business-readable Gherkin-like syntax suits: non-developer testers, BDD teams Postman + Newman GUI for authoring/collaboration suits: exploratory + CI via Newman CLI REST Assured Java library, fluent DSL suits: developers, lives in the codebase SoapUI GUI-focused, SOAP and REST suits: enterprise SOAP, regression suites they all verify the same contract — the choice is whose hands the tests live in

Karate — the business-readable API DSL

Karate is the standout for teams that want API tests authorable by people who aren't developers. It combines API testing, mocking, and performance testing using a plain-text Gherkin-like syntax, and it doesn't require programming knowledge for basic cases [2]. A Karate test reads almost like English:

Feature: login endpoint

Scenario: valid credentials return a token
Given url 'https://api.example.com/login'
And request { username: 'ave', password: 'secret' }
When method post
Then status 200
And match response contains { token: '#string' }

That's a complete, executable API test. The match keyword does deep JSON comparison and type-checking (#string means "any string"). Because the syntax is readable, a QA analyst or a product owner can review it; because it runs in CI, it gates every build. Karate also supports parallel execution out of the box and integrates with CI/CD pipelines [2]. The tradeoff is that the DSL, while approachable, has its own learning curve and isn't as flexible as a real programming language when you hit edge cases.

REST Assured — the developer's Java library

REST Assured is the other end of the spectrum: a Java library for testing REST APIs, using techniques borrowed from dynamic languages like Groovy [3]. It lives inside the application's codebase, written by developers, in the same language as the production code. A test looks like:

given()
.header("Authorization", token)
.body(Map.of("username", "ave"))
.when()
.post("/login")
.then()
.statusCode(200)
.body("token", notNullValue());

The fluent DSL makes the request-response chain readable, and because it's Java, the test has full access to the application's types, helpers, and test infrastructure. REST Assured suits teams where the API tests are owned by the developers who wrote the API, in a JVM stack. The tradeoff is that non-developers can't author or comfortably review these tests — the audience is narrower than Karate's.

Postman and Newman — GUI authoring, CLI running

Postman is the tool most people reach for first, because it's a GUI: you build requests, save them into collections, add assertions in JavaScript, and share the collection with the team [4]. Its strength is collaborative authoring and exploration — a tester can poke at an endpoint, build up a collection of saved requests, and hand it to a developer without either writing code in an IDE.

The piece that makes Postman suitable for CI is Newman, its command-line Collection Runner [5]. The same collection a tester built in the GUI runs unattended in CI via Newman, so the authoring interface (GUI) and the execution interface (CLI) are decoupled. This split is Postman's real architectural insight: human-friendly authoring, machine-friendly execution, one artifact (the collection JSON) bridging both.

# the same collection built in the GUI runs in CI:
newman run login-tests.json -e staging.json --reporters cli,json

SoapUI — the SOAP and enterprise heavyweight

SoapUI is the roadmap's pick for SOAP and REST functional testing at enterprise scale, with a graphical interface for creating automated functional, regression, and load tests [6]. It's most relevant where SOAP is still load-bearing — older enterprise integrations, financial systems, places where WS-* standards persist. For pure REST/JSON APIs, the other tools are usually a lighter fit, but SoapUI's strength in SOAP and its mature regression-suite tooling keep it relevant in those contexts.

Where Cypress and Playwright reappear

The roadmap lists Cypress and Playwright under backend automation as well as frontend, and the reason is that both have grown first-class API testing capabilities. Cypress's cy.request() and Playwright's request.newContext() let you write API tests in the same tool you use for end-to-end browser tests, which is genuinely useful: the same suite can verify "the API returns the right data" and "the UI renders that data correctly," catching the seam where the two disagree. The tradeoff is that a browser-testing tool isn't optimized for the sheer throughput of a dedicated API tool — for hundreds of API cases, Karate or REST Assured will be faster and more focused.

How I use this

The practical payoff is a decision rule based on the team's shape, not on abstract tool quality:

  • If the tests are authored by QA analysts or need business review → Karate. The Gherkin-like syntax is the enabler.
  • If the tests live with the developers in a JVM codebase → REST Assured. Full type safety, shared infrastructure.
  • If the team collaborates around a GUI and runs in CI → Postman + Newman. GUI authoring, CLI execution.
  • If SOAP is in the mix → SoapUI. Don't fight a browser-testing tool into SOAP territory.
  • If the API tests should share infrastructure with browser tests → Cypress or Playwright's API mode.

The deeper habit is treating the API contract as a first-class artifact — documented, versioned, and tested independently of any client that consumes it. API tests catch the defects that browser tests can't reach cheaply, and they run in seconds where a browser test takes minutes. A backend test suite that verifies the contract is the foundation; the frontend automation sits on top of it.

References

[1] Guru99, "Backend testing tutorial," 2023. [Online]. Available: https://www.guru99.com/what-is-backend-testing.html

[2] Karate Labs, "Karate framework," 2024. [Online]. Available: https://www.karatelabs.io/

[3] REST Assured, "REST-assured — testing and validation of REST services in Java," 2024. [Online]. Available: https://rest-assured.io

[4] Postman, "Learn Postman — getting started," 2024. [Online]. Available: https://learning.postman.com/docs/getting-started/introduction/

[5] Postman, "Newman CLI — command-line integration," 2024. [Online]. Available: https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/

[6] SoapUI, "SoapUI — getting started," 2024. [Online]. Available: https://www.soapui.org/getting-started/

Knowledge check · Question 1 of 5

The cleanest way to choose between Karate, REST Assured, and Postman for API testing is by…

Comments

Leave a Comment

You must be signed in to comment

0 Comments

No comments yet. Be the first to comment!