Skip to content

test: add unit and integration tests #38

Open

Description

@atsushi421

Summary

The project currently has no unit tests (only one integration/launch test exists). Tests should be added to ensure correctness and prevent regressions.

Scope

Unit tests (pure logic, via ament_add_ros_isolated_gtest)

  • cie_thread_configurator::create_callback_group_id: self-contained string-ID generation; good starting point
  • MultiThreadedExecutorInternal state machine / error handling: pre_spin() called twice throws, spin() without pre_spin() throws, get_thread_ids() without pre_spin() throws, and get_thread_ids() returns N unique TIDs
  • CallbackIsolatedExecutor add/remove/get bookkeeping for callback groups and nodes
    • Duplicate detection currently calls exit(EXIT_FAILURE), so these paths need gtest death tests (EXPECT_EXIT) unless they are converted to exceptions first (see Testability refactors below)
    • The constructor calls create_client_publisher(), so rclcpp::init() is required; this is not a pure unit test
  • ThreadConfiguratorNode YAML/config parsing and error paths (empty config_file, unknown scheduling policy, malformed YAML, hardware mismatch)
    • Requires extracting the parsing logic out of the constructor to make it testable
  • PrerunNode dump_yaml_config output and duplicate-ID detection

Integration tests (via launch_testing)

  • Minimal pub/sub exercising CallbackIsolatedExecutor directly (test_cie_pubsub.launch.py): test(cie): add minimal pub/sub launch_testing for CIE #57
  • Component container path end-to-end (ComponentManagerCallbackIsolated / composable nodes)
    • add_node_to_executor / remove_node_from_executor are protected overrides driven only through ComponentManager's load/unload services, so this is inherently integration rather than unit. The previously separate "unit test for ComponentManagerCallbackIsolated" item is folded in here; only is_clock_callback_group is unit-sized.
  • Non-ROS thread path end-to-end (spawn_non_ros2_thread -> NonRosThreadInfo -> non_ros_thread_callback in ThreadConfiguratorNode / PrerunNode)

CI

  • Extend the build-and-test workflow to also run gtest unit tests (it currently runs colcon test ... -L launch_test, so ament_add_gtest targets are never executed)
  • Widen --packages-select to also cover cie_thread_configurator (only callback_isolated_executor is tested today, so unit tests added to the configurator package would not run otherwise)

Activity

  1. changed the title [-]feat: Add tests for the CMake macro for registering nodes with CIE[/-] [+]feat: Add unit and integration tests[/+] on Apr 2, 2026
  2. added
    enhancement
    good first issue
    on Apr 2, 2026
  3. ran2810 commented on Jun 23, 2026

    @ran2810
    Contributor

    @atsushi421: I'd like to help with this. I see a test/ folder already exists — could you clarify which of the scoped items are already covered and which are still open?

  4. added
    good first issue
    and removed
    good first issue
    on Jun 23, 2026
  5. atsushi421 commented on Jun 23, 2026

    @atsushi421
    CollaboratorAuthor

    Thanks for offering to help, @ran2810! 🙏

    Current status:

    • ✅ Done: the only test so far is the minimal pub/sub launch test (test_cie_pubsub.launch.py), which exercises CallbackIsolatedExecutor directly.
    • ⬜ Open: everything else in the checklist, i.e. the four unit-test items, the component-container end-to-end integration test, and extending CI to run gtest unit tests (CI currently filters to -L launch_test).

    If you're looking for a good starting point, unit tests for cie_thread_configurator (e.g. create_callback_group_id) are the most self-contained. Feel free to pick any item and open a PR, happy to review.

  6. ran2810 commented on Jun 23, 2026

    @ran2810
    Contributor

    Thanks @atsushi421 ! I'll start with unit tests for cie_thread_configurator, focusing on create_callback_group_id in util.cpp as suggested. Following the ament_add_ros_isolated_gtest pattern. Will open a PR shortly.

  7. changed the title [-]feat: Add unit and integration tests[/-] [+]test: add unit and integration tests[/+] on Jun 23, 2026
  8. ran2810 commented on Jun 23, 2026

    @ran2810
    Contributor

    Opened #58 with unit tests for create_callback_group_id (the first unit-test item). It covers the namespace handling, trailing-separator strip, timer period formatting, and overload equivalence, using ament_add_ros_isolated_gtest.

  9. ran2810 commented on Jun 25, 2026

    @ran2810
    Contributor

    #58 (merged) covers the cie_thread_configurator unit-test item — the create_callback_group_id tests. The other items (executor unit tests, integration tests, CI integration) are still open.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions