Reqres API Testing Collection with Postman uploaded as json file to this repository as version 1 and version 2 files.
- Overview
The goal of this test plan is to verify the functionality of ReqRes API. This includes verifying API responses for correctness, testing error handling, validating schema consistency, and ensuring the API functions as expected in different conditions.
- Test Objectives
• Validate that the ReqRes API responds correctly to valid requests.
• Ensure the API handles invalid input and edge cases.
• Validate that the API responses match the expected structure and format.
- Test Strategy
3.1. Postman is used to test the following API endpoints:
- GET /api/users - Retrieve a list of users.
- GET /api/users/{id} - Retrieve a single user by indicated ID.
- GET /api/users/{id} - Single user by indicated ID not found.
- GET /api/unknown - Return a list of all available color resources.
- GET /api/unknown/{id} - Return the color resource of indicated ID.
- GET /api/unknown/{id} - Color resource by indicated ID not found.
- POST /api/users - Create a new user.
- PUT /api/users/{id} - Replace a user's full information with new data.
- PATCH /api/users/{id} - Modify only specific fields of a user's information.
- DELETE /api/users/{id} - Delete a user.
- POST /api/register - Register a new user (successful scenario).
- POST /api/register - Register a new user (unsuccessful scenario).
- POST /api/login - Authenticate a user (successful login).
- POST /api/login - Attempt to authenticate a user (unsuccessful login).
- GET /api/users?delay={id} - Retrieve user data with a delay.
3.2. Postman_collection_version1 file contains all above requests as indicated in reqres.in website.
- Test Scenarios and Cases
4.1 Functional Tests
o Objective: Verify that the API correctly returns a list of users.
o Test Steps:
-
Send a GET request to /api/users.
-
Check that the response status code is 200 OK.
-
Verify that the response contains a list of users (e.g., an array of user objects).
-
Validate the response body to ensure it contains the following attributes: id, email, first_name, last_name, avatar.
Tests in Postman:
//assertion test to verify response status
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
//checks that the response has a data field and that it's an array, to confirm the API returns a list of users in the correct format
pm.test("Response is an array", function () {
pm.response.to.have.jsonBody('data');
pm.expect(pm.response.json().data).to.be.an('array');
});
//checks that the first user in the response has all expected attributes (id, email, first_name, last_name, and avatar), to ensure each user object includes the required fields.
pm.test("User attributes are present", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.data[0]).to.have.property('id');
pm.expect(jsonData.data[0]).to.have.property('email');
pm.expect(jsonData.data[0]).to.have.property('first_name');
pm.expect(jsonData.data[0]).to.have.property('last_name');
pm.expect(jsonData.data[0]).to.have.property('avatar');
});
o Objective: Verify that the API returns the correct user when querying by a valid id.
o Test Steps:
-
Send a GET request to /api/users/{id} with an existing user ID (e.g., GET /api/users/2).
-
Check that the response status code is 200 OK.
-
Validate that the response contains user data with the required attributes (id, email, first_name, etc.).
Tests in Postman:
//assertion test to verify response status
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
//checks that the response has a data object and that this object contains id and email fields, confirming user details are returned—typically used when requesting a single user
pm.test("User data is returned", function () {
var jsonData = pm.response.json();
pm.expect(jsonData).to.have.property('data');
pm.expect(jsonData.data).to.have.property('id');
pm.expect(jsonData.data).to.have.property('email');
});
o Objective: Verify that the API does not return user with indicated ID.
o Test Steps:
-
Send a GET request to /api/users/{id} with a non existing user ID (e.g., GET /api/users/23).
-
Verify the response status code is 404 Not Found.
Tests in Postman:
//assertion test to verify response status
pm.test("Status code is 404", function () {
pm.response.to.have.status(404);
});
o Objective: Verify that the API correctly returns a list of all available color resources.
o Test Steps:
-
Send a GET request to /api/unknown.
-
Check that the response status code is 200 OK.
Tests in Postman:
//assertion test to verify response status
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
o Objective: Verify that the API correctly returns the color resource of indicated ID.
o Test Steps:
-
Send a GET request to /api/unknown/{id} with an existing user ID (e.g., GET /api/unknown/2).
-
Check that the response status code is 200 OK.
Tests in Postman:
//assertion test to verify response status
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
o Objective: Verify that the API does not return color resource with indicated ID.
o Test Steps:
-
Send a GET request to /api/unknown/{id} with a non existing user ID (e.g., GET /api/unknown/23).
-
Verify the response status code is 404 Not Found.
Tests in Postman:
//assertion test to verify response status
pm.test("Status code is 404", function () {
pm.response.to.have.status(404);
});
o Objective: Verify that the API creates a new user.
o Test Steps:
-
Send a POST request to /api/users with valid data in the request body (e.g., { "name": "morpheus", "job": "leader" }).
-
Verify the response status code is 201 or 202 Created.
-
Check that the response contains the name and job fields, and their values are correct.
Tests in Postman:
//assertion test to verify response status
pm.test("Successful POST request", function () {
pm.expect(pm.response.code).to.be.oneOf([201, 202]);
});
//checks that the response includes name and job fields with specific values ('morpheus' and 'leader'), to confirm the API correctly
returned or accepted user details—often used after a POST or PUT request
pm.test("Response contains user details", function () {
var jsonData = pm.response.json();
pm.expect(jsonData).to.have.property('name', 'morpheus');
pm.expect(jsonData).to.have.property('job', 'leader');
});
o Objective: Verify that the API updates an existing user.
o Test Steps:
-
Send a PUT request to /api/users/{id} with valid updated data in the request body (e.g., { "name": "morpheus", "job": "zion resident" }).
-
Verify the response status code is 200 OK.
-
Check that the response contains the updated name and job fields with their expected values.
Tests in Postman:
//assertion test to verify response status
pm.test('Status code is 200', function () {
pm.response.to.have.status(200);
});
//checks that the response includes name and job fields with specific values ('morpheus' and 'zion resident'), to confirm the API
correctly returned or accepted user details—often used after a POST or PUT request
pm.test("Response contains updated user details", function () {
var jsonData = pm.response.json();
pm.expect(jsonData).to.have.property('name', 'morpheus');
pm.expect(jsonData).to.have.property('job', 'zion resident');
});
o Objective: Verify that the API correctly updates the user resource when sending a PATCH request to /api/users/{id} with valid data.
o Test Steps:
-
Send a PATCH request to /api/users/{id} with an existing user ID (e.g., /api/users/2) and a valid request body.
-
Check that the response status code is 200 OK.
Tests in Postman:
//assertion test to verify response status
pm.test('Status code is 200', function () {
pm.response.to.have.status(200);
});
o Objective: Verify that the API deletes user with indicated ID.
o Test Steps:
-
Send a DELETE request to /api/users/{id} with a existing user ID (e.g., DELETE /api/users/2).
-
Verify the response status code is 204 No Content.
Tests in Postman:
//assertion test to verify response status
pm.test("Status code is 204", function () {
pm.response.to.have.status(204);
});
o Objective: Verify that the API successfully registers a user with valid credentials.
o Test Steps:
-
Send a POST request to /api/register with a valid data (e.g. { "email": "[email protected]", "password": "pistol" }).
-
Verify the response status code is 200 OK.
Tests in Postman:
//assertion test to verify response status
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
o Objective: Verify that the API does not register a user with invalid credentials.
o Test Steps:
-
Send a POST request to /api/register with invalid data (e.g. { "email": "sydney@fife" }).
-
Verify the response status code is 400 Bad Request and has indicated "error": "Missing password".
Tests in Postman:
//assertion test to verify response status
pm.test("Status code is 400", function () {
pm.response.to.have.status(400);
});
o Objective: Verify that the API successfully logs in a user with valid credentials.
o Test Steps:
-
Send a POST request to /api/login with a valid data (e.g. { "email": "[email protected]", "password": "cityslicka" }).
-
Verify the response status code is 200 OK.
Tests in Postman:
//assertion test to verify response status
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
o Objective: Verify that the API does not log in a user with invalid credentials.
o Test Steps:
-
Send a POST request to /api/login with a invalid data (e.g. { "email": "peter@klaven" }).
-
Verify the response status code is 400 Bad Request and contains error: "Missing password".
Tests in Postman:
//assertion test to verify response status
pm.test("Status code is 400", function () {
pm.response.to.have.status(400);
});
o Objective: Verify that the API correctly handles delayed responses based on the {id} parameter.
o Test Steps:
-
Send a GET request to /api/users?delay={id} with a valid {id} value (e.g., /api/users?delay=3).
-
Verify the response status code is 200 OK.
Tests in Postman:
//assertion test to verify response status
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
//assertion test to verify response time
pm.test('Response time is less than 6000ms', function () {
pm.expect(pm.response.responseTime).to.be.below(6000);
});
4.2. Postman_collection_version2 file contains all above requests with objectives, tests steps and assertion scripts.