diff --git a/controller_manager/test/test_spawner_unspawner.cpp b/controller_manager/test/test_spawner_unspawner.cpp index 78230d7404..cd2eee31f8 100644 --- a/controller_manager/test/test_spawner_unspawner.cpp +++ b/controller_manager/test/test_spawner_unspawner.cpp @@ -280,13 +280,16 @@ TEST_F(TestLoadController, spawner_test_with_params_file_string_parameter) lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED); ASSERT_EQ( cm_->get_parameter("ctrl_with_parameters_and_type.params_file").as_string(), test_file_path); + auto ctrl_node = ctrl_with_parameters_and_type.c->get_node(); ASSERT_THAT( ctrl_with_parameters_and_type.info.parameters_files, std::vector({test_file_path})); - ctrl_with_parameters_and_type.c->get_node()->declare_parameter( - "joint_names", std::vector({"random_joint"})); + if (!ctrl_node->has_parameter("joint_names")) + { + ctrl_node->declare_parameter("joint_names", std::vector({"random_joint"})); + } ASSERT_THAT( - ctrl_with_parameters_and_type.c->get_node()->get_parameter("joint_names").as_string_array(), + ctrl_node->get_parameter("joint_names").as_string_array(), std::vector({"joint0"})); }