0
0
Postmantesting~10 mins

Mock vs stub comparison in Postman - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a mock server in Postman.

Postman
pm.mockServer.create({ url: '[1]' });
Drag options to blanks, or click blank then click option'
Ahttps://api.example.com/mock
Bhttps://api.example.com/stub
Chttps://api.example.com/live
Dhttps://api.example.com/test
Attempts:
3 left
💡 Hint
Common Mistakes
Using a live or stub URL instead of a mock URL.
Forgetting to specify the URL in the mock server creation.
2fill in blank
medium

Complete the code to stub a response in Postman test script.

Postman
pm.stubResponse({ status: [1] });
Drag options to blanks, or click blank then click option'
A302
B404
C500
D200
Attempts:
3 left
💡 Hint
Common Mistakes
Using error status codes like 404 or 500 for a successful stub.
Confusing redirect status 302 with success.
3fill in blank
hard

Fix the error in the mock server creation code.

Postman
pm.mockServer.create({ url: '[1]' }); // URL must be a string
Drag options to blanks, or click blank then click option'
A12345
Bhttps://mock.api.com
Cmock.api.com
D'https://mock.api.com'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding extra quotes inside the string causing syntax errors.
Using numbers or incomplete URLs.
4fill in blank
hard

Fill both blanks to stub a JSON response with status 200.

Postman
pm.stubResponse({ status: [1], body: [2] });
Drag options to blanks, or click blank then click option'
A200
B{ "message": "Success" }
C404
D"Error"
Attempts:
3 left
💡 Hint
Common Mistakes
Using error status codes with success messages.
Passing plain strings instead of JSON objects for the body.
5fill in blank
hard

Fill all three blanks to create a mock server, set a stub response, and verify the status code.

Postman
const mock = pm.mockServer.create({ url: '[1]' });
pm.stubResponse({ status: [2] });
pm.test('Status code is [3]', () => {
  pm.expect(pm.response.code).to.eql([2]);
});
Drag options to blanks, or click blank then click option'
Ahttps://api.mockserver.com
B200
C200
Dhttps://api.stubserver.com
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing mock and stub URLs.
Using different status codes in stub and test causing assertion failures.