Skip to content

Refactor routing_params test and isolate HTTP response tests#1088

Merged
gittiver merged 3 commits into
CrowCpp:masterfrom
nicholashanson:refactor/isolate_http_response_tests
Sep 17, 2025
Merged

Refactor routing_params test and isolate HTTP response tests#1088
gittiver merged 3 commits into
CrowCpp:masterfrom
nicholashanson:refactor/isolate_http_response_tests

Conversation

@nicholashanson

Copy link
Copy Markdown
Contributor

Unit tests that only depend on crow::response were moved to unit_tests/test_http_response.cpp.

This is a proof-of-concept for splitting the monolithic file uinttest.cpp into multiple files that map one-to-one to files in include/crow.
The aims of this refactor are to:

  • Improve the readability and maintainability of unit tests.
  • Simplify onboarding for new developers.
  • Enable more granular testing and improve overall test coverage.

Below is a comparison between outputs before and after the refactor to validate that only the intended changes were made.

tests/unittest:

There is one more test than before because "simple_response_routing_params" was split into "simple_response" and "routing_params".

Before:

All tests passed (872 assertions in 93 test cases)

After:

All tests passed (872 assertions in 94 test cases)

test/unittest "custom_content_type"

No change.

Before:

Filters: "custom_content_types"
Randomness seeded to: 1196796123
(2025-09-15 15:05:54) [WARNING ] Unable to interpret mime type for content type 'custom/type'. Defaulting to text/plain.
(2025-09-15 15:05:54) [WARNING ] Unable to interpret mime type for content type 'notarealextension'. Defaulting to text/plain.
(2025-09-15 15:05:54) [WARNING ] Unable to interpret mime type for content type 'image/'. Defaulting to text/plain.
(2025-09-15 15:05:54) [WARNING ] Unable to interpret mime type for content type '/json'. Defaulting to text/plain.
===============================================================================
All tests passed (10 assertions in 1 test case)

After:

Filters: "custom_content_types"
Randomness seeded to: 3563733199
(2025-09-15 15:05:33) [WARNING ] Unable to interpret mime type for content type 'custom/type'. Defaulting to text/plain.
(2025-09-15 15:05:33) [WARNING ] Unable to interpret mime type for content type 'notarealextension'. Defaulting to text/plain.
(2025-09-15 15:05:33) [WARNING ] Unable to interpret mime type for content type 'image/'. Defaulting to text/plain.
(2025-09-15 15:05:33) [WARNING ] Unable to interpret mime type for content type '/json'. Defaulting to text/plain.
===============================================================================
All tests passed (10 assertions in 1 test case)

test/unittest "simple_response_routing_params":

Outputs are equivalent in aggregate.

Before:

Filters: "simple_response_routing_params"
Randomness seeded to: 3649381328
===============================================================================
All tests passed (14 assertions in 1 test case)

After:

Filters: "simple_response"
Randomness seeded to: 4187677161
===============================================================================
All tests passed (9 assertions in 1 test case)
Filters: "routing_params"
Randomness seeded to: 124073252
===============================================================================
All tests passed (5 assertions in 1 test case)

- Moved tests that depend solely on `crow::response` from unittest.cpp
  to tests/unit_tests/test_http_response.cpp for clearer separation of concerns.
- Renamed the original "simple_response_routing_params" test in
  unittest.cpp to "routing_params" to reflect this chage.
- Updated CMakeLists.txt to automatically include all sources under unit_tests/.
@gittiver gittiver linked an issue Sep 15, 2025 that may be closed by this pull request

@gittiver gittiver left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please replace globbing by explicit file listing

Comment thread tests/CMakeLists.txt Outdated
gittiver
gittiver previously approved these changes Sep 17, 2025
@gittiver
gittiver merged commit 07bbcd7 into CrowCpp:master Sep 17, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unittest.cpp refactor into multiple files

2 participants