一键导入
test-engineering
Scaffold, debug, and analyze test coverage for ROS 2 packages. Supports GTest, PyTest, and launch_testing.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scaffold, debug, and analyze test coverage for ROS 2 packages. Supports GTest, PyTest, and launch_testing.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Host orchestrator that drives an issue through the full per-issue lifecycle — dispatches each phase (review-issue → plan-task → review-plan → implement → review-code → triage-reviews → address-findings) as a fresh-context sub-agent, reads each phase's progress.md entry to choose the next action, and pauses at user checkpoints. Local-first: the PR is created at the end, never auto-pushes or auto-merges without confirmation.
Evaluate a GitHub issue against workspace principles and ADRs before work begins. Records findings in progress.md and best-effort posts them as a comment on the issue.
Independent evaluation of a committed work plan before implementation begins. Checks scope, approach, principle alignment, consequences, and ROS conventions.
Activate deployment mode for a live field deployment. Discovers the project's deployment config, detects dev/field side via field_mode.sh, and either creates a new deployment, first-activates an existing one (worktree/main-tree + per-host log + issue-sync push), or resumes an ongoing one. Loads the urgency contract (sterile-cockpit / mitigate-before-diagnose / time-box) into the current agent session.
Close out a field deployment. Verifies dev-side access, finds the open deployment issue, collects field logs, interviews the operator for corrections, consolidates the dev log, reconciles field code via SHA-preserving merge and /import-field-changes, opens the wrap-up PR (Closes
Lead reviewer that orchestrates specialist sub-reviews (static analysis, governance, plan drift, adversarial) to evaluate a PR or pre-push diff. Scales review depth to change risk. Produces a unified structured report and persists findings to progress.md.
| name | test-engineering |
| description | Scaffold, debug, and analyze test coverage for ROS 2 packages. Supports GTest, PyTest, and launch_testing. |
/test-engineering [<package-name>]
If no package name is given, operate on the package in the current directory.
Lifecycle position: Utility — use after audit-project flags test gaps,
or when asked to "write tests", "add test coverage", "debug test failures",
or "scaffold tests".
Covers the full test development lifecycle for ROS 2 packages: identifying coverage gaps, scaffolding test files, writing mock interfaces, and debugging failures. References existing templates rather than embedding them.
| Type | Framework | When to Use | Template |
|---|---|---|---|
| C++ unit tests | GTest | Testing functions, classes, algorithms in isolation | .agent/templates/testing/gtest_template.cpp |
| Python unit tests | PyTest | Testing Python node logic, utilities, data processing | .agent/templates/testing/pytest_template.py |
| Integration tests | launch_testing | Testing multi-node interactions, topic communication | .agent/templates/testing/launch_test_template.py |
Trigger: "What tests are missing?" or "Analyze test coverage"
Scan package structure:
test/ directoryAnalyze code:
Gap analysis:
Report:
Test Coverage Analysis for <package_name>:
Tested:
- component_a (test/test_component_a.cpp)
- utils module (test/test_utils.py)
Missing:
- node_b (no unit tests)
- ServiceHandler class (untested API)
- Integration: node_a -> node_b communication
Recommendation:
1. Add test/test_node_b.cpp for unit tests
2. Add test/test_integration.py for multi-node scenario
Trigger: "Create tests for X" or "Scaffold test file"
Read the appropriate template from .agent/templates/testing/ and adapt it:
test/test_<component>.cpp using gtest_template.cppCMakeLists.txt:
if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
ament_add_gtest(test_<component> test/test_<component>.cpp)
target_link_libraries(test_<component> <library_name>)
endif()
package.xml:
<test_depend>ament_cmake_gtest</test_depend>
test/test_<module>.py using pytest_template.pypackage.xml:
<test_depend>python3-pytest</test_depend>
test/test_<scenario>.py using launch_test_template.pyCMakeLists.txt:
if(BUILD_TESTING)
find_package(launch_testing_ament_cmake REQUIRED)
add_launch_test(test/test_<scenario>.py)
endif()
package.xml:
<test_depend>launch_testing_ament_cmake</test_depend>
<test_depend>launch_testing_ros</test_depend>
For integration tests involving launch files, consider using
ros2launch_session for clean lifecycle management. See
.agent/knowledge/launch_tooling.md.
Trigger: "Test X is failing" or "Debug this test"
In a layer worktree (preferred), use the generated convenience scripts:
./<layer>_ws/build.sh <package_name>
./<layer>_ws/test.sh <package_name>
In the main workspace, source the environment and use colcon directly:
source .agent/scripts/setup.bash && cd layers/main/<layer>_ws && \
colcon test --packages-select <package_name> --event-handlers console_direct+ && \
colcon test-result --verbose
| Type | Symptoms | Common Fix |
|---|---|---|
| Build failure | Missing test dependencies, CMake errors | Add <test_depend> to package.xml |
| Timeout | Test hangs, "timeout" in output | Increase timeout, check for deadlocks |
| Assertion failure | Expected vs actual mismatch | Fix logic or update expectations |
| Communication failure | Topics not received, services unavailable | Check QoS settings, topic names, discovery time |
| Race condition | Flaky — passes sometimes, fails others | Use event-based waits instead of time.sleep() |
rclpy.spin_until_future_complete() with explicit timeouts.wait_for_service(), condition-based waits, or
rclpy.spin_once() — never time.sleep().Trigger: "Create a mock publisher" or "Mock this service"
Common patterns for isolated testing:
Keep mocks minimal — just enough to test the component under test.
.agent/templates/testing/gtest_template.cpp — C++ unit test skeleton.agent/templates/testing/pytest_template.py — Python unit test skeleton.agent/templates/testing/launch_test_template.py — Integration test skeleton.agent/knowledge/launch_tooling.md — ros2launch_session API for
integration tests.agent/knowledge/documentation_verification.md — Command cookbook for
finding publishers, subscribers, parameters (useful for test planning)test_publisher_sends_correct_message_type().