Skip to content

This repository contains automated API test cases for the Booking API, focusing on reliability and performance. It includes a structured Postman environment and uses Newman for test execution and reporting. Key functionalities tested include booking creation, retrieval, updates, and deletions, with validations for status codes and response times.

Notifications You must be signed in to change notification settings

SanjanaVarma12/booking-api-testing

Repository files navigation

Booking API Testing Project

This project contains automated API tests for the Booking API, focusing on the end-to-end validation of booking-related functionalities. It leverages Postman for defining test cases and Newman for executing tests and generating detailed reports.

Project Overview

This project aims to ensure that the Booking API functions as expected across various endpoints. It verifies that the API handles different scenarios, such as booking creation, retrieval, updates, and cancellations, with correct responses and behavior.

Key Features of the API Tests:

  • Validation of Key Endpoints: Tests for critical endpoints like booking creation, retrieval, modification, and deletion.
  • Environment Management: Dynamic handling of API environment variables, such as base URL, API keys, and tokens.
  • Automated Testing with Newman: Execution of the tests using Newman with report generation in multiple formats (JSON, HTML).
  • Detailed Reporting: HTML reports generated with htmlextra for comprehensive analysis of test results.

Project Files

File Name Description
Booking_ApiTesting.json Postman collection with API test cases for the Booking API.
Environment_BookingAPI.json Postman environment file containing necessary environment variables.
Booking Api Testing.postman_test_run.json JSON file containing the result of the Postman test run, with logs.
newman-run-report-2024-09-22-12-51-08-091-0.html HTML report generated by Newman showing test case results and response details.
Booking Api Testing-2024-09-22-13-21-31-213-0.html HTMLextra Comprehensive HTML report generated by Newman, detailing test case results and API response data.

Setup and Prerequisites

Required Tools:

  • Node.js (v14 or later): Install Node.js from here.
  • Postman: Download Postman from here.
  • Newman: Install Newman globally on your system using the following command:
    npm install -g newman

Newman Reporter: htmlextra

To generate detailed HTML reports, install the htmlextra reporter:

npm install -g newman-reporter-htmlextra

How to Run the Tests

  1. Running Tests via Postman:
    • Open Postman.
    • Import the Postman collection (Booking_ApiTesting.json) and environment file (Environment_BookingAPI.json).
    • Select the appropriate environment.
    • Run the collection to execute the test cases directly in Postman.

image

  1. Running Tests via Newman: You can execute the tests from the command line using Newman.

    Basic Execution: Run the tests with the following command:

    newman run Booking_ApiTesting.json -e Environment_BookingAPI.json

image

  1. Execution with HTML Extra Report: To generate an HTML report after the tests:
    newman run Booking_ApiTesting.json -e Environment_BookingAPI.json -r htmlextra --reporter-htmlextra-export newman-run-report.html
    This command will create a detailed HTML report (newman-run-report.html) that you can open in any browser.

image

  1. Automated Testing with Continuous Integration (CI/CD): You can integrate the API testing suite into your CI/CD pipeline (e.g., Jenkins, GitLab CI) by configuring a job to run the Newman command. This ensures that the tests are executed on every code push or pull request, maintaining the stability of the API.

Test Descriptions

Endpoints Tested:

  • Create Booking (POST): Validates the ability to create a new booking with valid/invalid data.
  • Get Booking (GET): Retrieves booking details based on booking ID, testing valid and invalid scenarios.
  • Update Booking (PUT): Tests updating an existing booking with different sets of data.
  • Delete Booking (DELETE): Ensures bookings can be deleted correctly and handles edge cases where booking IDs don’t exist.

Assertions and Validations

  • Status Code Validation: Verifies that the API returns correct HTTP status codes (200, 201, 400, 404, etc.).
  • Response Time Validation: Ensures that the API responds within an acceptable time frame.
  • Schema Validation: Confirms that the API responses match the expected JSON schema.
  • Data Validation: Validates the correctness of data returned by the API, such as booking ID, dates, and user details.

Reports and Results

HTML Reports: The HTML reports generated by Newman using htmlextra are comprehensive. They include:

  • Overview of test results (number of passed/failed test cases).
  • Request/Response data for each API call.
  • Assertion details, showing whether the expected values matched the actual results.
  • Response times, highlighting slow API responses.
  • Errors and failures, including logs and messages for failed test cases.

Example reports:

  • newman-run-report-2024-09-22-12-51-08-091-0.html
  • Booking Api Testing-2024-09-22-13-21-31-213-0.html

Open these files in a browser to get a detailed view of the test run.

Future Enhancements

  • Integration with CI/CD: Implement seamless integration with Jenkins or GitLab for automated test execution on code commits.
  • Load Testing: Extend the test suite to include load testing for the Booking API to evaluate performance under high traffic.
  • Additional Test Cases: Expand the test coverage to include edge cases and security testing (e.g., rate limiting, and authorization failures).

Contributing

Feel free to contribute to this project by submitting issues or pull requests. Contributions should align with the project goals of improving the Booking API test coverage and ensuring API stability.

Key Features of the API Tests:

  • Validation of Key Endpoints: Tests for critical endpoints like booking creation, retrieval, modification, and deletion.
  • Environment Management: Dynamic handling of API environment variables, such as base URL, API keys, and tokens.
  • Automated Testing with Newman: Execution of the tests using Newman with report generation in multiple formats (JSON, HTML).
  • Detailed Reporting: HTML reports generated with htmlextra for comprehensive analysis of test results.

About

This repository contains automated API test cases for the Booking API, focusing on reliability and performance. It includes a structured Postman environment and uses Newman for test execution and reporting. Key functionalities tested include booking creation, retrieval, updates, and deletions, with validations for status codes and response times.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages