Skip to content

test: add unit and integration tests #38

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

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions