Skip to content

test(rclcpp_lifecycle): add unit tests for LifecycleNode::create_generic_publisher - #3396

Open
Aaravanand00 wants to merge 1 commit into
ros2:rollingfrom
Aaravanand00:add-lifecycle-generic-publisher-test
Open

Aaravanand00 wants to merge 1 commit into
ros2:rollingfrom
Aaravanand00:add-lifecycle-generic-publisher-test

Conversation

@Aaravanand00

Copy link
Copy Markdown
Contributor

Description

This pull request adds unit test coverage for LifecycleNode::create_generic_publisher in rclcpp_lifecycle.

While create_generic_subscription was recently introduced alongside test_lifecycle_generic_subscription.cpp, LifecycleNode::create_generic_publisher lacked dedicated unit tests. This PR introduces rclcpp_lifecycle/test/test_lifecycle_generic_publisher.cpp and registers it in rclcpp_lifecycle/CMakeLists.txt.

The new test suite covers :-

  • creation_and_destruction: Creation with valid topic name, typesupport string (test_msgs/msg/Strings), and QoS; verifies topic name accessor.
  • invalid_topic_name: Verifies that passing an invalid topic name throws rclcpp::exceptions::InvalidTopicNameError.
  • invalid_topic_type: Verifies that passing an invalid/unregistered typesupport string throws a std::runtime_error.
  • custom_publisher_options: Verifies passing custom rclcpp::PublisherOptions with an explicit callback group.
  • publish_serialized_message: Verifies publishing a rclcpp::SerializedMessage via the generic publisher without throwing.

Is this user-facing behavior change?

Did you use Generative AI?

Yes I was used to assist with structuring and writing the unit test cases and CMake registration.

Additional Information

  • Verified locally with ament_cpplint (0 problems found).
  • Verified locally with ament_uncrustify (0 code style divergence).

…ric_publisher

Signed-off-by: Aaravanand <aaravanand@gmail.com>
@Aaravanand00

Copy link
Copy Markdown
Contributor Author

Hi @fujitatomoya @clalancette While reviewing the recent addition of test_lifecycle_generic_subscription.cpp, I noticed that LifecycleNode::create_generic_publisher had no dedicated unit tests in rclcpp_lifecycle.

This pr fills that gap by adding unit tests covering successful initialization, topic name validation, invalid typesupport error handling, custom publisher options, and message publishing. This improves test coverage for rclcpp_lifecycle in line with ROS 2 Quality Level 1 standards and prevents regressions on generic publisher interfaces...

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

ABI Compliance Check

✅ Verdict: compatible

Library Verdict Summary
libcomponent_manager.so ✅ compatible No ABI changes detected.
librclcpp.so ✅ compatible No ABI changes detected.
librclcpp_action.so ✅ compatible No ABI changes detected.
librclcpp_lifecycle.so ✅ compatible No ABI changes detected.
✅ libcomponent_manager.so — full abidiff report

Compared:

  • Base: lib-base/libcomponent_manager.so
  • Head: lib-pr/libcomponent_manager.so @ 7afadb2
(empty report — no differences printed by abidiff)
✅ librclcpp.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp.so
  • Head: lib-pr/librclcpp.so @ 7afadb2
(empty report — no differences printed by abidiff)
✅ librclcpp_action.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp_action.so
  • Head: lib-pr/librclcpp_action.so @ 7afadb2
(empty report — no differences printed by abidiff)
✅ librclcpp_lifecycle.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp_lifecycle.so
  • Head: lib-pr/librclcpp_lifecycle.so @ 7afadb2
(empty report — no differences printed by abidiff)

Updated for commit 7afadb2 · check run · suppressions: /home/runner/work/_temp/ros2-abi-suppressions.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant