testcoe enhances Google Test by intercepting test events and providing visual feedback. It consists of several modular components working together.
┌─────────────────────────────────────┐
│ Test Application │
│ (Your Google Tests) │
└──────────────────┬──────────────────┘
│
┌──────────────────▼──────────────────┐
│ testcoe │
│ (Main Interface & API) │
└──────────────────┬──────────────────┘
│
┌──────────────────│──────────────────┐
│ │ │
┌───────▼───────┐ ┌──────▼──────┐ ┌──────▼──────┐
│ GridListener │ │SignalHandler│ │TerminalUtils│
│ (Visual Grid) │ │ (Crashes) │ │ (Terminal) │
└───────────────┘ └─────────────┘ └─────────────┘
- File:
src/testcoe.cpp,include/testcoe/testcoe.hpp - Purpose: Provides the public API for initialization and test execution
- Key Functions:
init()- Initializes Google Test and installs custom listenersrun()- Executes all testsrun_suite()- Executes specific test suiterun_test()- Executes specific test
- File:
src/grid_listener.cpp,include/testcoe/grid_listener.hpp - Purpose: Implements Google Test event listener for visual grid display
- Key Features:
- Tracks test execution state
- Updates terminal display in real-time
- Collects and displays failure information
- Shows execution time statistics
- File:
src/signal_handler.cpp,include/testcoe/signal_handler.hpp - Purpose: Catches crashes and provides detailed stack traces
- Platform Support:
- Unix/Linux/macOS: POSIX signal handlers (SIGSEGV, SIGABRT, etc.)
- Windows: Structured Exception Handling (SEH)
- Uses backward-cpp for stack trace generation
- File:
src/terminal_utils.cpp,include/testcoe/terminal_utils.hpp - Purpose: Cross-platform terminal operations
- Key Functions:
isAnsiEnabled()- Detects ANSI color supportclear()- Clears terminal screen
-
Initialization:
- User calls
testcoe::init() - Google Test is initialized
- GridListener is installed
- Signal handlers are registered
- User calls
-
Test Execution:
- User calls
testcoe::run() - Google Test begins execution
- GridListener receives events:
OnTestProgramStart- Initialize grid displayOnTestStart- Mark test as runningOnTestEnd- Mark test as passed/failedOnTestProgramEnd- Show final summary
- User calls
-
Crash Handling:
- If a test crashes, signal handler is triggered
- Stack trace is generated using backward-cpp
- Output streams are restored
- Detailed crash report is displayed
- Google Test (v1.16.0) - Test framework
- backward-cpp (v1.6) - Stack trace generation
- Windows: dbghelp, psapi and imagehlp
- Unix/Linux: Standard POSIX signal handling
- macOS: Standard POSIX signal handling
- Event Listener Pattern: Uses Google Test's event listener interface for non-invasive integration
- Stream Redirection: Temporarily redirects stdout/stderr during test execution to control output
- Cross-platform Abstraction: Platform-specific code isolated in dedicated sections
- Header-only Public API: Simple integration with single include