Skip to content

test(cpp): ✅ migrate unit tests to Catch2 - #264

Open
robertodr wants to merge 7 commits into
mainfrom
test-port-to-catch2
Open

test(cpp): ✅ migrate unit tests to Catch2#264
robertodr wants to merge 7 commits into
mainfrom
test-port-to-catch2

Conversation

@robertodr

@robertodr robertodr commented Aug 21, 2026

Copy link
Copy Markdown
Member

Since the unification of Python binding and C++ test compilation #152, the build times of the test step have increased. This is an experiment to check what's the impact of our unit test framework on compilation times in CI.

🤖 AI text below 🤖

Summary

Replace Boost.Test with Catch2 v3 for the C++ unit suite while preserving per-case CTest discovery and lockstep whole-suite MPI execution. This removes the Boost.Test binary dependency without removing Boost production utilities.

Changes

  • Port C++ test cases, fixtures, assertions, matchers, and generators to Catch2 v3.
  • Use system-first Catch2 discovery with a pinned v3.15.3 CPM fallback.
  • Preserve per-case serial CTest labels and whole-suite MPI rank variants, with deterministic ordering across ranks.
  • Add Catch2 installation support and remove Boost.Test provisioning from development and CI environments.
  • Update contributor and testing documentation.

Testing

  • Standard Python/workspace suite: 591 passed.
  • Serial C++ suite: 208 passed, 2 expected single-rank skips.
  • Two-rank MPI C++ suite: passed.
  • Wide TermIndex configuration: 618 Python tests and 209 C++ tests passed, with 2 expected skips.
  • Commit hooks: passed.
  • Documentation build was not run because npm is unavailable in the development container.

Checklist

  • Tests added or updated to cover the changes
  • Documentation updated (docstrings, docs/, CONTRIBUTING.md) if needed
  • CHANGELOG / release notes updated if applicable (not applicable: test infrastructure only)

AI/LLM disclosure

  • I did not use LLM tooling, or used it only privately for ideation
  • I used GitHub Copilot to help write this PR description
  • I used GitHub Copilot to generate or modify code

Important

By opening this PR I confirm that I have read CONTRIBUTING.md and I agree to the terms of the Contributor License Agreement.

Warning

If you're contributing on behalf of your employer, contact cla@algorithmiq.fi to arrange a Corporate CLA.

Replace Boost.Test with Catch2 v3 while preserving per-case CTest discovery and lockstep whole-suite MPI runs. Update dependency provisioning and testing documentation accordingly.

Assisted-by: GitHubCopilot:GitHub Copilot
@github-actions github-actions Bot added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file cpp ci tools labels Aug 21, 2026
@github-actions

Copy link
Copy Markdown

Docs preview: https://pr-264.monoprop-docs.pages.dev

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.70%. Comparing base (2953349) to head (636657b).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #264   +/-   ##
=======================================
  Coverage   97.70%   97.70%           
=======================================
  Files          14       14           
  Lines         742      742           
  Branches       98       98           
=======================================
  Hits          725      725           
  Misses         12       12           
  Partials        5        5           
Flag Coverage Δ
cpp 97.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@robertodr

Copy link
Copy Markdown
Member Author

It doesn't seem that using Catch2 vs Boost.Test makes that much of a difference in compile times. I believe this is a necessary evil due to templating in the library. I will try to compile the unit tests themselves as -O1 (instead of -O3) and see if that helps compile times.

@robertodr

Copy link
Copy Markdown
Member Author

Going to down to -O1 for the compilation of the unit tests (83c8182) cuts about 1 minute from the Install package step. Of course the execution is a bit slower, which more or less compensates.

TBH, I would merge this one. Catch2 is less bloated than Boost.Test as a unit test framework and I found its documentation more readable. Up to the reviewer.

Signed-off-by: Roberto Di Remigio Eikås <robertodr@users.noreply.github.com>
@robertodr
robertodr requested review from Panadestein and removed request for diagonal-hamiltonian August 24, 2026 09:34
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci cpp dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants