Test Engineer
Analyze test coverage and write high-quality Google Test tests for C++ projects.
Workflow
Determine the task type:
"Analyze coverage" or "find gaps" → Follow Coverage Analysis workflow "Write tests for X" → Follow Test Writing workflow "Improve tests for X" → Follow Test Improvement workflow
Coverage Analysis
Follow the structured process in references/coverage-analysis.md.
Steps:
- •Scan source directory for testable classes (files with
CorIprefix) - •Scan test directory for
*_test.cppfiles - •Map each source file to its test file (or mark as missing)
- •For covered files, assess test depth (shallow/moderate/deep)
- •Prioritize untested files by complexity, risk, and testability
- •Output a coverage report with recommendations
Exclude from analysis: vendored code (lua502/, lua512/, zLib/), pure macro/typedef headers, and build system files.
Writing New Tests
Consult references/test-patterns.md for conventions and examples.
Process
- •Read the source file's header (
.h) to understand the public API - •Read the implementation (
.cpp) to understand error paths and edge cases - •Check if related classes already have test patterns to follow
- •Write tests covering: construction, happy path, error paths, edge cases, round-trip, cleanup
- •Add the new
*_test.cppfile to the test CMakeLists.txt - •Build and run the new tests to verify they pass
Critical rules
- •Exception objects are heap-allocated:
throw new CRainmanException(...). Clean up withdestroy(), neverdelete. - •Use
CMemoryStorefor in-memory I/O testing — avoid writing to the real filesystem when possible. - •When filesystem access is needed, use
std::filesystem::temp_directory_path()with cleanup inTearDown(). - •Use
ASSERT_NE(ptr, nullptr)before dereferencing any pointer. - •Follow existing naming:
TEST(ClassName, BehaviorDescription)orTEST_F(ClassNameTest, BehaviorDescription). - •Preserve existing file headers with LGPL v2.1 copyright notices.
- •Boy-scout rule: When writing tests that exercise existing code, apply localized modern C++ improvements to the code under test if safe (e.g., add
override, replaceNULLwithnullptr, addconst). Keep such improvements within the scope of touched files.
Improving Existing Tests
- •Read the existing test file to understand current coverage
- •Read the source to identify untested methods, branches, and error conditions
- •Add new test cases for:
- •Untested public methods
- •Missing error/edge case paths
- •Missing round-trip (write→read) validation
- •Boundary conditions (empty, max, off-by-one)
- •Avoid modifying passing tests unless they have bugs
Build & Verify
After writing or modifying tests:
cmake --build build --config Debug ctest --test-dir build -C Debug -R "TestSuiteName" --output-on-failure
Always run the specific new/modified tests. Fix any compilation or assertion failures before considering the task complete.