Expand description
Test utilities for RCH.
Provides structured test logging, output capture, and debugging infrastructure for consistent test output across the codebase.
§Features
- JSONL test logs for CI debugging
- Structured phase markers (TEST START/PASS/FAIL)
- Terminal metadata capture
- Zero-boilerplate logging with
TestGuard
§Quick Start (Unit Tests)
For simple unit tests, use TestGuard which auto-logs pass/fail:
ⓘ
use rch_common::testing::TestGuard;
#[test]
fn test_simple() {
let _guard = TestGuard::new("test_simple");
// ... test logic ...
// TEST PASS logged automatically on success
// TEST FAIL logged automatically if test panics
}Or use the macro for automatic name detection:
ⓘ
use rch_common::test_guard;
#[test]
fn test_auto_name() {
let _guard = test_guard!(); // Uses "test_auto_name" as the test name
assert_eq!(1 + 1, 2);
}§Detailed Logging (E2E/Integration Tests)
For tests that need detailed phase logging, use TestLogger:
ⓘ
use rch_common::testing::{TestLogger, TestPhase};
#[test]
fn test_detailed() {
let logger = TestLogger::for_test("test_detailed");
logger.log(TestPhase::Setup, "Initializing test state");
// ... test logic ...
logger.log(TestPhase::Verify, "Checking results");
logger.pass(); // or logger.fail("reason")
}§Environment Variables
RCH_TEST_LOGGING=1: Force enable structured loggingRCH_TEST_LOGGING=0: Force disable (fastest, no I/O)- Default: Enabled in CI (
CI=true), disabled locally
Structs§
- Terminal
Info - Terminal metadata for debugging output issues.
- Test
Guard - Zero-boilerplate test logger that auto-logs pass/fail on drop.
- Test
LogEntry - A structured log entry for test execution.
- Test
Logger - Structured test logger that writes JSONL output.
- Test
Result - Aggregated test result for summary output.
Enums§
- Test
Phase - Test execution phases.
Functions§
- init_
global_ test_ logging - Initialize global JSONL logging for all tests.