Skip to content

Make all packages use gmock, not gtest #2162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

#include "test_chainable_controller_interface.hpp"

#include <gmock/gmock.h>
#include <memory>

#include "gmock/gmock.h"

using ::testing::IsEmpty;
using ::testing::SizeIs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
#ifndef TEST_CHAINABLE_CONTROLLER_INTERFACE_HPP_
#define TEST_CHAINABLE_CONTROLLER_INTERFACE_HPP_

#include <gmock/gmock.h>

#include <string>
#include <vector>

#include "controller_interface/chainable_controller_interface.hpp"
#include "gmock/gmock.h"
#include "hardware_interface/handle.hpp"

constexpr char TEST_CONTROLLER_NAME[] = "testable_chainable_controller";
Expand Down
2 changes: 1 addition & 1 deletion controller_interface/test/test_controller_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

#include "test_controller_interface.hpp"

#include <gmock/gmock.h>
#include <memory>
#include <string>
#include <vector>

#include "gmock/gmock.h"
#include "lifecycle_msgs/msg/state.hpp"
#include "rclcpp/executor_options.hpp"
#include "rclcpp/executors/multi_threaded_executor.hpp"
Expand Down
3 changes: 2 additions & 1 deletion controller_interface/test/test_controller_with_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

#include "test_controller_with_options.hpp"

#include <gtest/gtest.h>
#include <string>

#include "gmock/gmock.h"

class FriendControllerWithOptions : public controller_with_options::ControllerWithOptions
{
FRIEND_TEST(ControllerWithOption, init_with_overrides);
Expand Down
3 changes: 1 addition & 2 deletions controller_interface/test/test_force_torque_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
#ifndef TEST_FORCE_TORQUE_SENSOR_HPP_
#define TEST_FORCE_TORQUE_SENSOR_HPP_

#include <gmock/gmock.h>

#include <memory>
#include <string>
#include <vector>

#include "gmock/gmock.h"
#include "semantic_components/force_torque_sensor.hpp"

// implementing and friending so we can access member variables
Expand Down
4 changes: 2 additions & 2 deletions controller_interface/test/test_gps_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <algorithm>
#include <array>
#include <string>
#include <vector>

#include "gmock/gmock.h"
#include "hardware_interface/handle.hpp"
#include "hardware_interface/loaned_state_interface.hpp"
#include "semantic_components/gps_sensor.hpp"
Expand Down
3 changes: 1 addition & 2 deletions controller_interface/test/test_imu_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
#ifndef TEST_IMU_SENSOR_HPP_
#define TEST_IMU_SENSOR_HPP_

#include <gmock/gmock.h>

#include <memory>
#include <string>
#include <vector>

#include "gmock/gmock.h"
#include "semantic_components/imu_sensor.hpp"

// implementing and friending so we can access member variables
Expand Down
3 changes: 1 addition & 2 deletions controller_interface/test/test_led_rgb_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
#ifndef TEST_LED_RGB_DEVICE_HPP_
#define TEST_LED_RGB_DEVICE_HPP_

#include <gmock/gmock.h>

#include <array>
#include <limits>
#include <memory>
#include <string>
#include <vector>

#include "gmock/gmock.h"
#include "semantic_components/led_rgb_device.hpp"

class TestableLedDevice : public semantic_components::LedRgbDevice
Expand Down
3 changes: 1 addition & 2 deletions controller_interface/test/test_pose_sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
#ifndef TEST_POSE_SENSOR_HPP_
#define TEST_POSE_SENSOR_HPP_

#include <gmock/gmock.h>

#include <array>
#include <memory>
#include <string>
#include <vector>

#include "gmock/gmock.h"
#include "semantic_components/pose_sensor.hpp"

class TestablePoseSensor : public semantic_components::PoseSensor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
#ifndef TEST_SEMANTIC_COMPONENT_COMMAND_INTERFACE_HPP_
#define TEST_SEMANTIC_COMPONENT_COMMAND_INTERFACE_HPP_

#include <gmock/gmock.h>

#include <memory>
#include <string>

#include "geometry_msgs/msg/pose.hpp"
#include "gmock/gmock.h"
#include "semantic_components/semantic_component_command_interface.hpp"

// implementing and friending so we can access member variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
#ifndef TEST_SEMANTIC_COMPONENT_INTERFACE_HPP_
#define TEST_SEMANTIC_COMPONENT_INTERFACE_HPP_

#include <gmock/gmock.h>

#include <memory>
#include <string>

#include "geometry_msgs/msg/wrench.hpp"
#include "gmock/gmock.h"
#include "semantic_components/semantic_component_interface.hpp"

// implementing and friending so we can access member variables
Expand Down
10 changes: 2 additions & 8 deletions controller_manager/test/controller_manager_test_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,20 @@
#ifndef CONTROLLER_MANAGER_TEST_COMMON_HPP_
#define CONTROLLER_MANAGER_TEST_COMMON_HPP_

#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include <chrono>
#include <memory>
#include <string>
#include <thread>
#include <vector>

#include "controller_interface/controller_interface.hpp"

#include "controller_manager/controller_manager.hpp"
#include "controller_manager_msgs/srv/switch_controller.hpp"

#include "gmock/gmock.h"
#include "rclcpp/executors.hpp"
#include "rclcpp/utilities.hpp"

#include "std_msgs/msg/string.hpp"

#include "ros2_control_test_assets/descriptions.hpp"
#include "std_msgs/msg/string.hpp"

namespace
{
Expand Down
3 changes: 1 addition & 2 deletions controller_manager/test/test_controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gmock/gmock.h>
#include <memory>
#include <string>
#include <vector>

#include "controller_manager/controller_manager.hpp"
#include "controller_manager_msgs/msg/controller_manager_activity.hpp"
#include "controller_manager_test_common.hpp"
#include "gmock/gmock.h"
#include "lifecycle_msgs/msg/state.hpp"
#include "rclcpp/executor.hpp"
#include "test_chainable_controller/test_chainable_controller.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gtest/gtest.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "controller_manager/controller_manager.hpp"
#include "controller_manager_test_common.hpp"
#include "gmock/gmock.h"
#include "hardware_interface/types/lifecycle_state_names.hpp"
#include "lifecycle_msgs/msg/state.hpp"
#include "ros2_control_test_assets/test_hardware_interface_constants.hpp"
Expand Down
6 changes: 2 additions & 4 deletions controller_manager/test/test_controller_manager_srvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <memory>
#include <random>
#include <string>
#include <vector>

#include "controller_manager_test_common.hpp"

#include "controller_interface/controller_interface.hpp"
#include "controller_manager_msgs/srv/list_controller_types.hpp"
#include "controller_manager_msgs/srv/list_controllers.hpp"
#include "controller_manager_msgs/srv/list_hardware_interfaces.hpp"
#include "controller_manager_msgs/srv/switch_controller.hpp"
#include "controller_manager_test_common.hpp"
#include "gmock/gmock.h"
#include "lifecycle_msgs/msg/state.hpp"
#include "test_chainable_controller/test_chainable_controller.hpp"
#include "test_controller/test_controller.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gtest/gtest.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "controller_manager/controller_manager.hpp"
#include "controller_manager_test_common.hpp"
#include "gmock/gmock.h"
#include "ros2_control_test_assets/descriptions.hpp"
#include "test_controller/test_controller.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gtest/gtest.h>
#include <memory>
#include <string>
#include <vector>

#include "controller_manager/controller_manager.hpp"
#include "controller_manager_test_common.hpp"
#include "gmock/gmock.h"
#include "test_controller/test_controller.hpp"

using ::testing::_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gtest/gtest.h>
#include <memory>
#include <string>
#include <unordered_map>
Expand All @@ -21,6 +20,7 @@

#include "controller_manager/controller_manager.hpp"
#include "controller_manager_test_common.hpp"
#include "gmock/gmock.h"
#include "lifecycle_msgs/msg/state.hpp"
#include "test_chainable_controller/test_chainable_controller.hpp"
#include "test_controller/test_controller.hpp"
Expand Down
7 changes: 2 additions & 5 deletions controller_manager/test/test_hardware_management_srvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <memory>
#include <string>
#include <vector>

#include "controller_manager_test_common.hpp"

#include "controller_manager/controller_manager.hpp"
#include "controller_manager_msgs/msg/hardware_component_state.hpp"
#include "controller_manager_msgs/srv/set_hardware_component_state.hpp"
#include "controller_manager_test_common.hpp"
#include "gmock/gmock.h"
#include "hardware_interface/types/lifecycle_state_names.hpp"
#include "lifecycle_msgs/msg/state.hpp"
#include "rclcpp/parameter.hpp"
Expand Down
3 changes: 1 addition & 2 deletions controller_manager/test/test_hardware_spawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gtest/gtest.h>

#include <cstdlib>
#include <memory>
#include <string>
#include <vector>

#include "controller_manager/controller_manager.hpp"
#include "controller_manager_test_common.hpp"
#include "gmock/gmock.h"
#include "lifecycle_msgs/msg/state.hpp"
#include "test_chainable_controller/test_chainable_controller.hpp"
#include "test_controller/test_controller.hpp"
Expand Down
4 changes: 1 addition & 3 deletions controller_manager/test/test_load_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <memory>
#include <string>
#include <tuple>
#include <vector>

#include "controller_manager/controller_manager.hpp"
#include "controller_manager_test_common.hpp"
#include "gmock/gmock.h"
#include "lifecycle_msgs/msg/state.hpp"
#include "test_controller/test_controller.hpp"
#include "test_controller_failed_init/test_controller_failed_init.hpp"
Expand Down
4 changes: 1 addition & 3 deletions controller_manager/test/test_release_interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <string>
#include <vector>

#include "controller_manager/controller_manager.hpp"
#include "controller_manager_test_common.hpp"
#include "gmock/gmock.h"
#include "lifecycle_msgs/msg/state.hpp"
#include "test_controller/test_controller.hpp"
#include "test_controller_with_interfaces/test_controller_with_interfaces.hpp"
Expand Down
3 changes: 1 addition & 2 deletions controller_manager/test/test_spawner_unspawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <gtest/gtest.h>

#include <cstdlib>
#include <memory>
#include <string>
#include <vector>

#include "controller_manager/controller_manager.hpp"
#include "controller_manager_test_common.hpp"
#include "gmock/gmock.h"
#include "lifecycle_msgs/msg/state.hpp"
#include "test_chainable_controller/test_chainable_controller.hpp"
#include "test_controller/test_controller.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
//
// Author: Denis Stogl

#include <gmock/gmock.h>

#include <cmath>
#include <string>
#include <unordered_map>
#include <vector>

#include "gmock/gmock.h"
#include "hardware_interface/loaned_command_interface.hpp"
#include "hardware_interface/loaned_state_interface.hpp"
#include "hardware_interface/resource_manager.hpp"
Expand Down Expand Up @@ -2210,6 +2209,6 @@ TEST_F(TestGenericSystem, prepare_command_mode_switch_works_with_all_example_tag
int main(int argc, char ** argv)
{
rclcpp::init(argc, argv);
testing::InitGoogleTest(&argc, argv);
testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}
Loading
Loading