ROS has a framework for running tests, called rostest.
The pieces needed for a test is:
Example CMakeLists.txt entry:
add_rostest_gtest(test_serial_subscriber serial_subscriber.test test_serial_subscriber.cpp) add_dependencies(test_serial_subscriber serial_subscriber_example) target_link_libraries(test_serial_subscriber serial test_tools ${catkin_LIBRARIES} ${GTEST_LIBRARIES})
To compile all tests:
rsmake tests
To run all tests:
rsmake run_tests
To run a single test:
rostest robosub <test>