Replace GoogleTest with doctest for unit testing
GoogleTest fails to compile on recent clang versions and is years out of date. Migrated to doctest, a modern single-header testing library with no external dependencies.
Changes
-
Replaced GoogleTest with doctest (v2.4.12)
- Removed
UnitTest/GoogleTest/directory (~30K lines) - Added
UnitTest/doctest.handdoctest_main.cc - Updated
UnitTestBaseto include doctest instead of gtest
- Removed
-
Converted test macros
-
TEST(Suite, Name)→TEST_CASE("Suite - Name") -
TEST_F(Fixture, Name)→TEST_CASE_FIXTURE(Fixture, "Fixture - Name") - Added macro compatibility layer in
UnitTest.hforEXPECT_*/ASSERT_*→CHECK/REQUIRE
-
-
Updated test fixtures
- Converted
SetUp()→ constructors,TearDown()→ destructors - Removed
overridekeywords and::testing::Testbase class - Affected:
TimeoutTest,KEMFieldTest,KGeoBagShapeTest, and capacitance test fixtures
- Converted
-
Documentation updates
- Updated
README.mdandCMakeLists.txtto reference doctest
- Updated
Test Status
All existing unit tests pass except 2 pre-existing failures in IntegratorsTest (unrelated to migration):
- Kommon: 13/13 (89 assertions)
- KGeoBag: 13/13 (101 assertions)
- Kasper: 59/61 (306 assertions)
Example
Before:
TEST_F(KEMFieldCubeTest, Capacitance_GaussAnalytic) {
// test body
}
After:
TEST_CASE_FIXTURE(KEMFieldCubeTest, "KEMFieldCubeTest - Capacitance_GaussAnalytic") {
// test body
}
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com
- Triggering command:
/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
Original prompt
This section details on the original issue you should resolve
<issue_title>Use doctest instead of GoogleTest</issue_title> <issue_description>GoogleTest fails to compile on recent clang versions (see KATRIN-Experiment/Kassiopeia#85 ). GoogleTest currently considers to add a new dependency to the central Google base library "abseil" ( https://github.com/google/googletest/issues/2883 ). Since our fork of GoogleTest is many years out of date and integrating a new version would be a significant effort anyways, it seems reasonable to move to the dependency-less single-header testing library
doctest: https://github.com/doctest/doctest</issue_description>Comments on the Issue (you are @copilot in this section)
- Fixes KATRIN-Experiment/Kassiopeia#87
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.