Kassiopeia icon indicating copy to clipboard operation
Kassiopeia copied to clipboard

Replace GoogleTest with doctest for unit testing

Open Copilot opened this issue 4 months ago • 0 comments

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.h and doctest_main.cc
    • Updated UnitTestBase to include doctest instead of gtest
  • 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.h for EXPECT_*/ASSERT_*CHECK/REQUIRE
  • Updated test fixtures

    • Converted SetUp() → constructors, TearDown() → destructors
    • Removed override keywords and ::testing::Test base class
    • Affected: TimeoutTest, KEMFieldTest, KGeoBagShapeTest, and capacitance test fixtures
  • Documentation updates

    • Updated README.md and CMakeLists.txt to reference doctest

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:

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.

Copilot avatar Nov 04 '25 10:11 Copilot