Unit tests for acecode, built with GoogleTest.
cmake -B build -DBUILD_TESTING=ON ... # (usual toolchain args)
cmake --build build --target acecode_unit_tests
ctest --test-dir build --output-on-failureTests mirror module paths and omit the source group prefix (D15):
| Production source | Test location |
|---|---|
| base/platform | tests/platform |
| domain/session | tests/session |
| adapters/tool | tests/tool |
| engine/agent | tests/agent |
| host/session_host | tests/session_host |
| apps/tui | tests/tui |
Keep the same subdirectories for a nested module. Shared fixtures live under tests/test_support; AgentLoop fixtures inject dependencies before start, and characterization fixtures isolate HOME, provider scripts and session data.
Adding a new test file needs no CMake edit — tests/CMakeLists.txt globs
*_test.cpp (note: singular _test, not _tests).
- Pure logic: serializers, validators, parsers, glob matchers, hash functions.
- Headless state machines: tool progress line buffering, line/chunk processors.
- Schema roundtrips:
SessionMeta,ChatMessage, config files.
- The TUI entry point
src/apps/cli/main.cppand the full terminal loop are validated manually. All TUI implementations compile once inacecode_tui; tests link those production archives through the source-freeacecode_testableinterface. No testable TUI allowlist is required. Executable entry points and WebView shells remain outside the test aggregate. - LLM provider HTTP paths (
CopilotProvider,OpenAiCompatProvider) — need mock HTTP server; left to a future integration-tests change. - Real provider/network end-to-end behavior needs configured services. AgentLoop protocol, ownership and lifecycle regressions use injected providers and local HTTP fixtures in the unit suite.
- Test suite name (first arg to
TEST) matches the unit under test (SanitizeTitle,SessionStorage,Base64Encode). - Prefer
EXPECT_*overASSERT_*except when later assertions would crash on the failing state (e.g.ASSERT_EQ(vec.size(), 1u)beforevec[0]). - Use
testing::TempDir()orstd::filesystem::temp_directory_path()for any file I/O — never write to the repo tree. - Shared helpers (
StubLlmProvider, the sandbox / channelstest_support, theme resources, computer-use smoke helpers) live undertests/test_support/<area>/and are included with the full prefix, e.g.#include "test_support/agent/stub_provider.hpp". Project headers use the module-root form ("session/session_storage.hpp"), never../.