Now accepting guest editorial from SAP, Oracle, Workday and ServiceNow practitioners.Pitch a guide
The Sign-Off Table

Lesson 6 of 6

From manual calls to reusable API tests

10 min

Listen to this lesson

0:00 / 7:55

A request that worked once in your client is a note, not a test. A test runs again tomorrow, on another system, with other data, without you, and tells the truth about the result. At Contoso, Ravi's automation portfolio counts about 30 API checks out of 240 automated regression tests; each one started as a manual call. This lesson is the checklist for turning a call into a test, whatever tool runs it.

Five changes that make a call a test

Manual callReusable test
Host, client and user typed into the URLEnvironment variables: one set for sandbox, CMQ client 100, CMR client 100
Token copied by hand from a previous responseA setup step that fetches the CSRF token and keeps cookies
Data typed into the bodyData from a file or a test data recipe, one row per case
Eyeballing the responseAssertions on status, structure and business values
Whatever data is left behindSetup and cleanup that restore a known state

The differences between a call and a test.

The shape of a reusable API test: environment and data in, assertions and evidence out.
The Sign-Off Table · thesignofftable.com/academy/sap-tst-211

Assertions that matter

  • Status: the exact code expected (201, not "2xx").
  • Structure: required properties present, with the expected types; compare against a stored metadata snapshot to catch service changes after an upgrade.
  • Business values: the sold-to party, amount and currency on sales order 1000457; the role on business partner 17100001.
  • Side effects: after a write, read back; for interfaces, check the follow-on document or IDoc.
  • Negative cases: missing token gives 403, stale ETag gives 412, invalid value gives 400 with the expected message.

What belongs at the API level

CheckAPI testUI test
Service available, authorized, returns the right dataBest fit: fast and preciseSlow and indirect
Validation rules and error messages from the backendGood fit with negative data rowsNeeded once to see the message reaches the user
Interfaces from partners and other systemsBest fit: same entry point as productionNot applicable
Field layout, navigation, app behaviorNot applicableBest fit
Test data setup for UI testsBest fit: create data through APIsSlow and brittle

Deciding where a check belongs; course <a href="/academy/sap-tau-203">sap-tau-203</a> covers API automation strategy in depth.

API checks run right after each import into CMR, so a broken service stops the line before business testers start.
The Sign-Off Table · thesignofftable.com/academy/sap-tst-211

Data-driven design

Keep the request generic and the data in a table. The same address-creation test can run for a fleet customer, an aftermarket customer and a one-off customer by changing the row, not the request. Wei's test data recipes provide stable keys in CMQ and CMR; a test that needs a fresh document creates it in setup and records its key. Never hard-code a document number that a refresh will change.

CaseBusiness partnerCountryExpected statusExpected message
Valid US address17100001US201None
Missing postal code17100001US400Postal code required (text varies by release)
Unknown partner99999999US400 or 404Partner does not exist
Second ship-to depot17100006US201None

Illustrative course data: one request, four rows of data and expectations.

Secrets, evidence and the pipeline

Credentials live in the runner's secret store or environment, never in shared collections, test data files or screenshots. Evidence for each run records the request with secrets removed, the response, the system and client, the time and the result, and goes to SAP Cloud ALM with the test case it belongs to. Ravi's pipeline runs the API checks after each transport import into CMR, so a broken service shows up before the business regression starts.

  1. Day 1Manual callWorks in the sandbox and in CMQ
  2. Day 2ParameterizedEnvironment variables, token setup, data file
  3. Day 3AssertedStatus, structure, business values, negative cases
  4. Day 4Self-cleaningSetup and cleanup; runs twice in a row with the same result
  5. Day 5In the pipelineRuns after imports into CMR; evidence in SAP Cloud ALM
A realistic path from one working call to a regression test.
The Sign-Off Table · thesignofftable.com/academy/sap-tst-211

Plan for maintenance from the start. Keep the saved $metadata of every service the suite uses, and after each SAP upgrade or feature pack compare it with the new one before running the suite: added properties are usually harmless, removed or retyped ones break tests and interfaces alike. Released APIs on the Accelerator Hub also carry a state (for example active or deprecated) and a successor when SAP replaces them; a deprecated API in your suite is a work item for the next release, not a surprise in the one after.

What would you do?

Ravi reviews a new API test from a contractor. It passes reliably in CMQ. The request URL contains the CMQ host and client 100, the body contains business partner 17100001 and a hard-coded address ID, and the only assertion is status 2xx. CMR is refreshed quarterly from production. What is the most important change before it joins the regression set?

Key points
  • Parameterize environments, automate the token step, and drive data from files or recipes.
  • Assert exact status, structure and business values, plus negative cases.
  • Setup and cleanup make tests repeatable; never hard-code refreshed document numbers.
  • Keep secrets out of collections; store evidence with the test case.

Check your understanding · not graded

Lesson check

  1. 1. Why store host and client as environment variables?

  2. 2. What is the weakness of asserting only "status 2xx"?

  3. 3. Where should API credentials live?

  4. 4. What proves a write test is repeatable?