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.
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.
- 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.
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. |
- 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
To generate detailed HTML reports, install the htmlextra
reporter:
npm install -g newman-reporter-htmlextra
- 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.
-
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
- Execution with HTML Extra Report:
To generate an HTML report after the tests:
This command will create a detailed HTML report (newman-run-report.html) that you can open in any browser.
newman run Booking_ApiTesting.json -e Environment_BookingAPI.json -r htmlextra --reporter-htmlextra-export newman-run-report.html
- 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.
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.
- 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.
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.
- 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).
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.
- 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.