Name API tests so a failure explains itself

A CI job fails with:

Output
✗ Request 7  GET https://staging.example.com/v2/x/41  500
    ✗ test 1 — Expected 500 to equal 200.

Someone has to open the collection to find out what "Request 7" is, then the script to find out what "test 1" checked. Names are the cheapest documentation a test has, and they show up everywhere: the CLI output, JUnit files, HTML reports, Jira issues, Slack alerts.

Requests

BeforeAfter
POST /ordersCreate order
test2Create order without items (rejected)
GET order copyGet order as another customer (forbidden)
New Request (3)Refund order (partial)

The path in results is Collection/Folder/Request, so the folder supplies context and the name doesn't have to repeat it. Orders API/Refunds/Partial refund reads better than Orders API/Refunds/Refunds - partial refund of order.

Name negative tests after the expected outcome ("(rejected)", "(forbidden)", "(not found)"). When a negative test fails, the name tells the reader that the API accepted something it should have refused, which is the opposite of what the status code suggests.

Checks

A check name should finish the sentence "This request is broken because…":

BeforeAfter
status is 200order is created
test 1total includes VAT
has property idresponse has the new order's id
422refund above the paid amount is refused
JavaScript
pm.test('refund above the paid amount is refused', () => {
  pm.expect(pm.response.code).to.equal(422);
});

The failure message still has the mechanics ("Expected 200 to equal 422"); the name adds the meaning.

No-code assertions on the Tests tab get a name like "Status code equals 201" by default, which is fine for simple checks. Give a label to the ones that encode a business rule.

Data-driven runs

With a CSV or JSON data file, one check runs once per row. Put the row's case in the name, or every failure looks the same:

JavaScript
const label = pm.iterationData.get('case');
pm.test(`${label}: rejected with 400`, () => pm.response.to.have.status(400));

Suites and packages

In a test suite, a package card shows its name and, after a run, how many of its requests failed. Checkout: happy path and Checkout: payment declined say more than Package 1 and Package 2.

Where the names end up

  • CLI: ✗ Orders API/Refunds/Partial refund … ✗ refund is capped at the paid amount.
  • JUnit: each request is a test case, shown in your CI's test view. See JUnit reports explained.
  • Alerts and Jira issues: the run's target and the failed requests.
  • Run history: the per-request rows, and Changes since… between runs.

Good names make every one of these readable without opening the collection.