Writing tests in pytest
Pytest is the canonical way to write Python tests for Roboticks. Theroboticks package adds four decorators and a set of rclpy-aware assertion helpers on top of stock pytest. Nothing else changes — your fixtures, your conftest.py, your parametrize idioms keep working.
The four decorators
All four stack and can decorate the same test in any order. See the SDK decorator reference for full semantics.
Decorators are inert without the platform. Locally they only mark functions. The pytest plugin reads them at collection time and writes them into JUnit XML on session-end. See Pytest plugin.
Rclpy assertion helpers
The SDK ships ROS2-aware assertions inroboticks.assertions. They spin a node briefly, wait for the predicate, and raise an informative AssertionError on timeout. The helpers are guarded: importing the module on a host without rclpy installed raises a clear RuntimeError instead of an opaque ImportError.
Subscribe-and-assert on /cmd_vel
Service call response
Action result
Conftest pattern
Spin uprclpy once per test session, and once per test give every test a clean executor. This pattern works for unit-scope ROS tests; for system tests use launch_testing instead.
Parametrize and @confirms
@confirms is per-test-function, not per-test-id. Parametrized variants all confirm the same requirement set — which is usually what you want:
What the plugin emits
Per test, in the JUnit XML:Next
Fault injection
Drop topics, delay messages, kill nodes — under a context manager.
MCAP capture
Record bag files per test for failure forensics.
Launch testing
System tests that bring up multiple nodes.
Decorator reference
Full signatures and edge cases.