feat(tests): Add gtests for each node and simulator class

This commit is contained in:
2025-11-26 16:13:00 +01:00
parent 9eba61eb6e
commit 1a3d92158d
5 changed files with 621 additions and 9 deletions

View File

@@ -50,15 +50,30 @@ install(DIRECTORY launch config
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
find_package(ament_cmake_gtest REQUIRED)
# Simulator unit tests
ament_add_gtest(test_simulator test/test_simulator.cpp src/simulator/Simulator.cpp)
target_include_directories(test_simulator PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
ament_target_dependencies(test_simulator rclcpp)
# IMU simulator integration tests
ament_add_gtest(test_imu_simulator test/test_imu_simulator.cpp
src/g2_2025_imu_data_simulator_node/nodes/imu_data_simulator.cpp
src/simulator/Simulator.cpp)
target_include_directories(test_imu_simulator PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/g2_2025_imu_data_simulator_node)
ament_target_dependencies(test_imu_simulator rclcpp sensor_msgs geometry_msgs)
# Wheel simulator integration tests
ament_add_gtest(test_wheel_simulator test/test_wheel_simulator.cpp
src/g2_2025_wheel_data_simulator_node/nodes/wheel_data_simulator.cpp
src/simulator/Simulator.cpp)
target_include_directories(test_wheel_simulator PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/g2_2025_wheel_data_simulator_node)
ament_target_dependencies(test_wheel_simulator rclcpp std_msgs)
endif()
ament_package()