| name | test |
| description | Run unit tests using CTest. Use when user asks to run tests, test the code, check test results, or mentions test failures. |
| allowed-tools | Bash, Read, Glob |
Test Skill
Run unit tests for the OrderParserProcessor project using CTest.
Prerequisites
- Project must be built with
-DBUILD_TESTS=ONoption - Tests are typically located in service directories under
test/subdirectories (e.g.,backend/test/,connectivity/test/) - Identify the build directory (check for existing build directories)
Instructions
- Find the build directory (search for directories like
build/,cmake-build-*/,backend/build/, etc.) - Check if tests were built (look for test executables or check CMake cache for BUILD_TESTS)
- If tests not built, rebuild with tests:
cmake -B <build_dir> -DBUILD_TESTS=ON && cmake --build <build_dir> - Identify which specific tests to run based on user request or context
- Run the specific tests using CTest with pattern matching
- Report test results (passed/failed counts)
- If tests fail, show failure details and relevant error messages
Test Commands
Run Specific Tests (Recommended)
# Run tests matching a pattern
ctest --test-dir <build_dir> -R <test_name_pattern> --output-on-failure
# Examples:
ctest --test-dir <build_dir> -R backend --output-on-failure
ctest --test-dir <build_dir> -R connectivity --output-on-failure
ctest --test-dir <build_dir> -R script_processor --output-on-failure
Run All Tests
ctest --test-dir <build_dir> --output-on-failure
Run with Parallel Execution (Recommended for speed)
# Use -j2 or higher to run tests in parallel
# Some tests use timers, so parallel execution speeds things up
ctest --test-dir <build_dir> -j2 --output-on-failure
# Adjust based on available CPU cores
ctest --test-dir <build_dir> -j4 --output-on-failure
List Available Tests
ctest --test-dir <build_dir> -N
Run Tests Verbosely
ctest --test-dir <build_dir> -R <pattern> --verbose
Rerun Failed Tests
ctest --test-dir <build_dir> --rerun-failed --output-on-failure
Build Tests (if not already built)
cmake -B <build_dir> -DBUILD_TESTS=ON
cmake --build <build_dir>
Test Organization
Tests are organized per service/component:
backend/test/- Backend service testsconnectivity/test/- Connectivity module tests- Other component directories may have their own
test/subdirectories
Best Practices
- Run specific tests rather than the entire suite when working on a particular component
- Use parallel execution (
-j2or higher) when running multiple tests - some tests use timers - List tests first with
-Nto see what's available - Use pattern matching with
-Rto target relevant tests
Common Issues
- No tests found: Ensure
BUILD_TESTS=ONwas set during CMake configuration - Test compilation errors: Check test source files in component
test/directories - Test failures: Review output with
--output-on-failureflag - Build directory missing: Run build first with tests enabled
- Wrong build directory: Search for actual build directory location
- Tests taking too long: Use
-jfor parallel execution or run specific tests with-R
Success Criteria
- Requested tests pass successfully
- No segmentation faults or crashes
- Test output is clear and informative
- Targeted tests run efficiently