Skip to main content

Overview

The C++ framework has two test suites:
SuiteBinaryLLM RequiredHardwareWhat it tests
Unit teststests_mockNoAnyAll core modules with mocked dependencies
Integration teststests_integrationYesWindows + LLM serverReal LLM calls, MCP connections, agent workflows
Both suites use Google Test (fetched automatically by CMake).

Unit Tests

Unit tests are built by default and run without an LLM server. They cover all eight core modules:
ModuleTest fileWhat it covers
Agent looptest_agent.cppState machine, multi-step planning, error recovery
Tool registrytest_tool_registry.cppRegistration, lookup, execution, parameter schemas
Tool integrationtest_tool_integration.cppEnd-to-end tool calling with mocked LLM
JSON utilitiestest_json_utils.cppMulti-strategy JSON extraction, fallback parsing
MCP clienttest_mcp_client.cppJSON-RPC protocol, stdio transport, tool discovery
Consoletest_console.cppTerminalConsole and SilentConsole output
Clean consoletest_clean_console.cppCleanConsole TUI, word-wrap, ANSI colors
Typestest_types.cppAgentConfig, Message, ToolInfo, ParsedResponse

Building Unit Tests

Unit tests are built by default when building the C++ framework as a standalone project (GAIA_BUILD_TESTS=ON). The standard build commands from the Quickstart produce the tests_mock binary automatically:
cd cpp
cmake -B build -G "Visual Studio 17 2022" -A x64
cmake --build build --config Release
Binary: build\Release\tests_mock.exe
If you’re consuming gaia_core as a sub-project (via FetchContent or add_subdirectory), tests are off by default. Pass -DGAIA_BUILD_TESTS=ON to enable them.

Running Unit Tests

Run the test binary directly:
build\Release\tests_mock.exe --gtest_color=yes
Or via CTest:
ctest --test-dir build -C Release --output-on-failure

Filtering Tests

Google Test supports test filtering via --gtest_filter:
# Run only agent tests
tests_mock --gtest_filter="AgentTest.*"

# Run only JSON utility tests
tests_mock --gtest_filter="JsonUtils.*"

# Run a specific test
tests_mock --gtest_filter="ToolRegistryTest.RegisterAndExecute"

Integration Tests

Integration tests exercise the full stack — real LLM inference, live MCP server connections, and actual agent workflows. They require:
  • A running LLM server (Lemonade recommended) with a model loaded
  • Windows (the tested agents use PowerShell)
  • uvx on PATH (for MCP tests)
Test fileWhat it covers
test_integration_llm.cppLLM chat completions, tool-calling responses
test_integration_mcp.cppMCP server connection, tool discovery, tool execution
test_integration_wifi.cppWi-Fi agent end-to-end diagnostic flow
test_integration_health.cppHealth agent MCP-based system diagnostics

Building Integration Tests

Integration tests are not built by default. Enable them with the GAIA_BUILD_INTEGRATION_TESTS CMake option:
cmake -B build -G "Visual Studio 17 2022" -A x64 -DGAIA_BUILD_INTEGRATION_TESTS=ON
cmake --build build --config Release
This produces the tests_integration binary alongside the unit test binary.
Do not mix unit and integration tests in CTest. If you enable integration tests, CTest will discover both suites. Run tests_integration separately with an LLM server running — otherwise CTest will hang waiting for the LLM connection.

Running Integration Tests

  1. Start an LLM server with a model loaded:
    lemonade-server serve
    
  2. Set environment variables (optional — defaults shown):
    set GAIA_CPP_BASE_URL=http://localhost:8000/api/v1
    
    set GAIA_CPP_TEST_MODEL=Qwen3-4B-Instruct-2507-GGUF
    
  3. Run the tests:
    build\Release\tests_integration.exe --gtest_color=yes
    
Integration tests have a 300-second timeout per test. If a test hangs, verify the LLM server is responding at the configured URL.

CI Pipeline

The C++ CI workflow (.github/workflows/build_cpp.yml) runs four jobs on every PR that touches cpp/:
JobRuns onWhat it validates
Build & TestUbuntu + Windows (cloud)CMake build + unit tests
Install TestUbuntu + Windows (cloud)cmake --install + find_package round-trip
Shared LibraryUbuntu + Windows (cloud)BUILD_SHARED_LIBS=ON compiles cleanly
Integration TestsSTX hardware (self-hosted)Full stack: LLM + MCP + WiFi + Health
The integration test job runs on AMD STX hardware with a real Lemonade Server and Qwen3-4B model. It is treated as non-blocking in CI (infrastructure issues on self-hosted runners don’t fail the PR).

Adding New Tests

Unit Tests

Add your test file to cpp/tests/ and register it in CMakeLists.txt:
add_executable(tests_mock
    # ... existing test files ...
    tests/test_your_module.cpp   # Add here
)
Follow the existing pattern — include <gtest/gtest.h>, use TEST() or TEST_F() macros, and mock LLM responses where needed. See test_agent.cpp for mocking examples.

Integration Tests

Add your test file to cpp/tests/integration/ and register it in the tests_integration target in CMakeLists.txt:
add_executable(tests_integration
    # ... existing test files ...
    tests/integration/test_integration_your_feature.cpp   # Add here
)
Integration tests should:
  • Read GAIA_CPP_BASE_URL and GAIA_CPP_TEST_MODEL from environment variables
  • Use reasonable timeouts (the CI sets 300s per test)
  • Be idempotent — no permanent side effects