This repository was archived by the owner on Jan 20, 2026. It is now read-only.
Postman tests for compulsory part 2#28
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the test infrastructure for the HotelBooking application by introducing a dedicated test environment with its own database seeding logic and expanding automated API testing capabilities through Postman iteration data.
Key changes:
- Introduced
TestDbInitializerto seed a test-specific database with predefined data for consistent testing - Added dynamic Postman test cases using iteration data to verify success, conflict, and bad request scenarios
- Updated CI/CD workflow to use the Test environment with iteration-based API testing
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
Postman/bookingTestCases.json |
New iteration data file defining test cases for success (201), conflict (409), and bad request (400) scenarios |
Postman/HotelBooking.postman_collection.json |
Added pre-request scripts to dynamically generate payloads and test scripts to validate expected status codes |
HotelBooking.WebApi/Properties/launchSettings.json |
Added "test" launch profile for running the application in Test environment locally |
HotelBooking.WebApi/Program.cs |
Refactored database initialization to use different initializers based on environment (Development vs Test) |
HotelBooking.Infrastructure/TestDbInitializer.cs |
New test database initializer that seeds customers, rooms, and bookings with specific date ranges |
HotelBooking.Core/Services/BookingManager.cs |
Enhanced CreateBooking to populate the Room property on the booking object |
.github/workflows/build-test.yaml |
Updated to set Test environment and use iteration data for Postman tests |
Comments suppressed due to low confidence (2)
Postman/HotelBooking.postman_collection.json:1
- The pre-request script uses the same
randomIdforcustomerIdandroomId, which will likely not match existing entities in the test database. TheTestDbInitializercreates specific customers and rooms with their own IDs. Consider using fixed IDs that correspond to the seeded test data to ensure valid bookings.
{
Postman/HotelBooking.postman_collection.json:1
- The pre-request script uses the same
randomIdforcustomerIdandroomId, which will likely not match existing entities in the test database. TheTestDbInitializercreates specific customers and rooms with their own IDs. Consider using fixed IDs that correspond to the seeded test data to ensure valid bookings.
{
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements to the testing and initialization of the HotelBooking application, with a focus on supporting a dedicated test environment and enhancing automated API tests. The most significant changes include the addition of a test database initializer, improved environment configuration for tests, and more robust Postman API test cases.
Test Environment and Database Initialization:
TestDbInitializerclass to seed the test database with sample data, ensuring consistent test conditions. The application now uses this initializer when running in the "Test" environment, while the regularDbInitializeris used for development. (HotelBooking.Infrastructure/TestDbInitializer.cs,HotelBooking.WebApi/Program.cs) [1] [2]HotelBooking.WebApi/Program.cs,HotelBooking.WebApi/Properties/launchSettings.json) [1] [2]CI/CD and Automated Testing Enhancements:
ASPNETCORE_ENVIRONMENTto "Test" during CI runs, ensuring the test database and configuration are used. (.github/workflows/build-test.yaml).github/workflows/build-test.yaml,Postman/bookingTestCases.json) [1] [2]API Testing Improvements:
Postman/HotelBooking.postman_collection.json) [1] [2]Booking Creation Logic:
CreateBookingmethod to fetch and assign the fullRoomentity to the booking, ensuring the booking object is fully populated before saving. (HotelBooking.Core/Services/BookingManager.cs)