🧪 G3 · Assertions with pm.test

G3 · Assertions with pm.test: `pm.test(...)` is Postman's JavaScript-written **assertion statement** — the direct counterpart of JUnit's `assertEquals`/`assertThat` in Java, only

`pm.test(...)` is Postman's JavaScript-written **assertion statement** — the direct counterpart of JUnit's `assertEquals`/`assertThat` in Java, only the language and syntax differ. Saying `pm.response.to.have.status(201)` does the SAME job as `assertEquals(201, response.getStatus())` in JUnit. So why isn't "send the request, eyeball it" enough? Because eyeballing does not SCALE and is not REPEATABLE — writing `pm.test` makes this check run AUTOMATICALLY and CONSISTENTLY on every run. **For a deep `pm.test`/Chai assertion guide → see the `/postman` page.**

🎬 From Eyeballing to Automated Verification

Eyeball check (does not scale)

Automatic on every run

A tester eyeballs the response after every request — tiring and error-prone.

`pm.test(...)` is written in the `Tests` tab — the check becomes CODE.

Now status and body are AUTOMATICALLY verified on every run — repeatedly, with the same rigor.

The Order for Writing an Assertion

Run the POST /api/v1/bugs request, observe the response.

Write in the Tests tab…

Turn the status and body check into code with pm.test(...).

Read the green/red result in the Test Results tab.

Order the process for writing and verifying a pm.test.

Send the request, see the raw response