Random or fixed test data? When to use each

{{$randomEmail}} in a signup body means every run creates a new user and never hits "email already exists". It also means the failure you saw at 3 a.m. had an email you'll never see again. Random and fixed test data each solve a problem and cause another. The trick is knowing which field needs which.

What to randomize

Fields where the only requirement is "don't collide with anything":

JSON
{
  "email": "{{$randomEmail}}",
  "username": "qa_{{$guid}}",
  "idempotencyKey": "{{$guid}}",
  "company": "{{$randomCompanyName}}"
}

These never change what the test is testing. They just keep runs from tripping over each other. See dynamic variables for the full list.

What to fix

Fields the assertion depends on:

JSON
{
  "amount": 100.00,
  "currency": "EUR",
  "couponCode": "SAVE10"
}
JavaScript
pm.test('a 10% coupon on 100.00 EUR gives 90.00', () => {
  pm.expect(pm.response.json().total).to.equal(90);
});

A random amount here would need the test to recompute the expected total, which means duplicating the business logic in the test. When the two agree, you've proven they're the same code, not that it's right.

Make random failures reproducible

When a test with random data fails, you need the values it used. Log them:

JavaScript
// Pre-request
const email = `qa+${require('uuid').v4().slice(0, 8)}@example.com`;
pm.variables.set('email', email);
console.log('signup email', email);

Script console output shows in the app's console, in --verbose CLI output, and in the JSON report, so the failing run tells you exactly what it sent. Then reproduce it with a fixed value: --var [email protected].

Edge cases: on purpose, not by luck

{{$randomInt}} gives a number between 0 and 1000. It'll rarely give you 0, never -1, never 2147483648. If boundaries matter, list them in a data file:

quantities.csv
quantity,expectedStatus
0,422
1,201
999,201
1000,422
-1,422

That's a fixed, readable list of cases that runs every time. See test input validation at the boundaries.

Names and text

Random names and addresses ({{$randomFullName}}, {{$randomStreetAddress}}) make test data look realistic in admin screens and logs. Keep a few fixed nasty ones too: an apostrophe (O'Brien), non-Latin letters (Zoë Łukasz 王), an emoji, a 255-character name. Those find more bugs than a thousand random "John Smith"s.