Challenge - 5 Problems
Random Data Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Postman script generating a random integer?
Consider this Postman pre-request script snippet that generates a random integer between 1 and 10 inclusive. What is the possible output stored in the variable
randomInt?Postman
const randomInt = Math.floor(Math.random() * 10) + 1; pm.environment.set('randomInt', randomInt); console.log(randomInt);
Attempts:
2 left
💡 Hint
Remember how Math.random() and Math.floor() work together to generate integers in a range.
✗ Incorrect
Math.random() generates a decimal from 0 (inclusive) up to but not including 1. Multiplying by 10 gives a number from 0 up to but not including 10. Math.floor() rounds down to the nearest integer, so possible values are 0 to 9. Adding 1 shifts the range to 1 to 10 inclusive.
❓ assertion
intermediate2:00remaining
Which assertion correctly verifies a random email format in Postman test script?
You want to check that a randomly generated email stored in
pm.environment.get('randomEmail') matches the pattern username@domain.com. Which assertion is correct?Postman
const email = pm.environment.get('randomEmail');Attempts:
2 left
💡 Hint
Check which assertion method tests a string against a regular expression.
✗ Incorrect
The .to.match() method tests if the string matches the given regex pattern. Other methods like .equal(), .include(), and .have.string() do not accept regex as argument for matching.
🔧 Debug
advanced2:00remaining
Why does this Postman script fail to generate a random UUID correctly?
This script tries to generate a random UUID and set it as an environment variable. Why does it fail?
Postman
const uuid = '{{$guid}}'; pm.environment.set('randomUUID', uuid); console.log(uuid);
Attempts:
2 left
💡 Hint
Check how Postman handles dynamic variables in scripts.
✗ Incorrect
In pre-request scripts, {{$guid}} used directly in a string is not replaced automatically. It returns the string '{{$guid}}' literally. To generate a UUID, you must use pm.variables.replaceIn('{{$guid}}') or a custom function.
🧠 Conceptual
advanced2:00remaining
What is the main advantage of using Postman dynamic variables for random data generation?
Why should testers prefer Postman dynamic variables like {{$randomInt}} or {{$randomEmail}} over hardcoded test data?
Attempts:
2 left
💡 Hint
Think about test data uniqueness and test reliability.
✗ Incorrect
Dynamic variables generate fresh random data each time, preventing conflicts like duplicate emails or IDs in tests. This reduces false failures caused by repeated data.
❓ framework
expert3:00remaining
Which Postman test script snippet correctly generates and validates a random date within the last 30 days?
You want to generate a random date within the last 30 days and verify it is not in the future. Which snippet does this correctly?
Attempts:
2 left
💡 Hint
Check how the randomTime is calculated between past and now timestamps.
✗ Incorrect
Option A correctly calculates randomTime as a value between past.getTime() and now.getTime() by adding a random fraction of the difference to past.getTime(). Other options invert or misuse the range causing invalid dates.