RclexTesting.DSL.Actions (RclexTesting (Experimental) v0.1.0)

Copy Markdown View Source

Mock ROS action servers, send goals, and assert action activity.

mock_action/3 records incoming goals, feedback, and results. Use send_goal/3 to invoke an action server, and use the expect_* and refute_goal assertions to verify the recorded action lifecycle.

Summary

Functions

Assert that the mocked action produced a new feedback message.

Assert that the mocked action produced feedback matching predicate.

Assert that the mocked action server received a new goal.

Assert that the mocked action server received a goal matching predicate.

Assert that the mocked action produced a result.

Assert that the mocked action produced a result matching predicate.

Register a test action server implementation on the scenario node.

Assert that no new goal is submitted to the mocked action server.

Assert that no goal matching predicate is submitted.

Send a goal to an action server and return the goal UUID.

Functions

expect_feedback(action_name, action_type)

@spec expect_feedback(String.t(), module()) :: struct()

Assert that the mocked action produced a new feedback message.

expect_feedback "/navigate", Navigate

expect_feedback(action_name, action_type, predicate)

@spec expect_feedback(String.t(), module(), (struct() -> boolean())) :: struct()

Assert that the mocked action produced feedback matching predicate.

expect_feedback "/navigate", Navigate, fn fb -> fb.progress == 100 end

expect_goal(action_name, action_type)

@spec expect_goal(String.t(), module()) :: struct()

Assert that the mocked action server received a new goal.

expect_goal "/navigate", Navigate

expect_goal(action_name, action_type, predicate)

@spec expect_goal(String.t(), module(), (struct() -> boolean())) :: struct()

Assert that the mocked action server received a goal matching predicate.

expect_goal "/navigate", Navigate, fn goal -> goal.x == 10 end

expect_result(action_name, action_type)

@spec expect_result(String.t(), module()) :: struct()

Assert that the mocked action produced a result.

expect_result "/navigate", Navigate

expect_result(action_name, action_type, predicate)

@spec expect_result(String.t(), module(), (struct() -> boolean())) :: struct()

Assert that the mocked action produced a result matching predicate.

expect_result "/navigate", Navigate, fn result -> result.success end

mock_action(action_name, action_type, handler)

@spec mock_action(String.t(), module(), (struct(), function() -> struct())) :: :ok

Register a test action server implementation on the scenario node.

Goals, feedback, and results are all recorded in the collector. The handler receives (goal, publish_feedback) and must return a result struct. Cleanup is automatic when the scenario ends.

mock_action "/navigate", Navigate, fn goal, publish_feedback ->
  publish_feedback.(%Navigate.Feedback{progress: 50})
  publish_feedback.(%Navigate.Feedback{progress: 100})
  %Navigate.Result{success: true}
end

refute_goal(action_name, action_type)

refute_goal(action_name, action_type, opts)

@spec refute_goal(String.t(), module(), keyword()) :: :ok

Assert that no new goal is submitted to the mocked action server.

refute_goal "/navigate", Navigate

refute_goal(action_name, action_type, predicate, opts \\ [])

@spec refute_goal(String.t(), module(), (struct() -> boolean()), keyword()) :: :ok

Assert that no goal matching predicate is submitted.

refute_goal "/navigate", Navigate, fn goal -> goal.x < 0 end

send_goal(action_name, action_type, goal, opts \\ [])

@spec send_goal(String.t(), module(), struct(), keyword()) :: binary()

Send a goal to an action server and return the goal UUID.

Starts an action client on the scenario node on first use.

goal_uuid = send_goal "/navigate", Navigate, %Navigate.Goal{x: 10, y: 20}