C++ reference
roboticks_cpp is a header-only ament_cmake INTERFACE library. It ships:
- The
ROBOTICKS_CONFIRMSmacro. - A thread-safe
ConfirmsRegistry. - gtest-compatible rclcpp assertion helpers.
- An optional
gtest_maintarget that wires the registry dump into the standard gtest exit.
CMake
The package exports two targets viaament_cmake:
ROBOTICKS_CONFIRMS
The macro expands to a
ConfirmsRegistry::instance().add(...) call. It must appear inside a gtest test body. Place it as the first statement so the registry record is created before any assertion can short-circuit:
(token, [req_ids...], file, line) — file and line are captured via __FILE__ and __LINE__.
ConfirmsRegistry
Methods
Thread safety
All mutating methods are guarded by an internalstd::mutex. instance() is safe under C++11 magic statics. Read methods (size, dump) take a shared view under the same lock — concurrent dumps and adds serialise but don’t deadlock.
JSON dump shape
Assertion helpers
Templated free functions inroboticks_cpp:::
FAIL() macro so they appear in the standard gtest summary and stop the current test. Timeouts surface as FAIL() << "timed out waiting for ...";.
Example
Stitching into JUnit
ament_cmake_gtest writes per-test JUnit XML at test_results/<package>/<test>.gtest.xml. The Python-side stitcher merges confirms.json from the registry dump:
SuiteName.TestName (gtest format) ↔ SuiteName_TestName (registry token). When you use colcon test --event-handlers roboticks+, this happens automatically.
v0.1 is registry-only. The C++ side records confirms IDs; the stitcher merges them into JUnit. Phase 11 will ship a native JUnit reporter so the macro writes properties directly — wire shape unchanged.
Manual registry dump
If you bring your ownmain():
Linking with colcon test
roboticks+ event handler ships in roboticks_cpp and:
- Locates the JUnit XML colcon wrote.
- Locates the
confirms.jsonthe test binary dumped. - Stitches and writes a side-by-side
*.junit.xmlfor upload.
Headers
Next
Writing tests in C++
Tutorial with full examples.
Wire contract
The schema the stitcher targets.
Pytest plugin
The Python-side equivalent.
Coverage
gcov/lcov wiring inside colcon.