Testing¶
The HTTPServer project maintains a rigorous testing strategy combining unit tests for core logic and integration tests for end-to-end behavior.
Testing Infrastructure¶
The project uses two primary testing frameworks:
GoogleTest: For C++ unit testing of library components.
Pytest: For high-level integration testing of the server binary and its network behavior.
Unit Tests¶
Unit tests are located in tests/unit_tests/ and focus on individual components in isolation.
Key test suites include:
test_httpparser.cpp: Comprehensive testing of HTTP request parsing, including edge cases and malformed requests.test_router.cpp: Validates routing logic, static directory serving, and dynamic path matching.
To run unit tests:
make unit_test
Integration Tests¶
Integration tests are located in tests/integration_tests/ and utilize Python’s pytest framework. These tests spin up the actual server binary and perform real network requests over the loopback interface.
Key coverage areas include:
Basic Functionality: Verifying GET/POST requests and response codes.
Server Lifecycle: Testing startup, shutdown, and signal handling.
Network Features: Validating HTTPS/TLS, port redirection, and keep-alive connections.
Performance & Safety: Testing rate limiting, thread pool behavior, and concurrent connection management.
Error Handling: Ensuring the server correctly handles internal errors and invalid client behavior.
To run integration tests:
make integration_test
Running All Tests¶
To run the entire test suite (unit and integration):
make test