Skip to content

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

Merged
clalancette merged 1 commit into
ros2:rollingfrom
Aaravanand00:add-lifecycle-generic-publisher-test
Nov 17, 2026
Merged

clalancette merged 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).

@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 @ 68ee077
(empty report — no differences printed by abidiff)
✅ librclcpp.so — full abidiff report

Compared:

  • Base: lib-base/librclcpp.so
  • Head: lib-pr/librclcpp.so @ 68ee077
(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 @ 68ee077
(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 @ 68ee077
(empty report — no differences printed by abidiff)

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

@Aaravanand00

Copy link
Copy Markdown
Contributor Author

@fujitatomoya @clalancette ptal

@clalancette clalancette left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments below are mostly because our test times are already through the roof, and I don't want to add in new tests unless they add something substantial. Let me know what you think.

@Aaravanand00
Aaravanand00 force-pushed the add-lifecycle-generic-publisher-test branch from 7afadb2 to a00cbd3 Compare November 7, 2026 10:31
@clalancette

Copy link
Copy Markdown
Contributor

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

…ric_publisher

Signed-off-by: Aaravanand <aaravanand@gmail.com>
@clalancette
clalancette force-pushed the add-lifecycle-generic-publisher-test branch from a00cbd3 to 68ee077 Compare November 17, 2026 14:53
@clalancette

Copy link
Copy Markdown
Contributor

Rebased so it got the ament_cppcheck fix from rolling, now re-running CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@clalancette
clalancette merged commit 9e66d4d into ros2:rolling Nov 17, 2026
11 checks passed
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.

2 participants