User Tools

Writing Tests

ROS has a framework for running tests, called rostest.

Setting Stuff Up

The pieces needed for a test is:

  1. the node to test (also known as UUT or Unit Under Test)
  2. a file with tests (also known as the test or testbench)
  3. a .test file that launches the UUT and testbench

Example CMakeLists.txt entry:

add_dependencies(test_serial_subscriber serial_subscriber_example)              
target_link_libraries(test_serial_subscriber serial test_tools ${catkin_LIBRARIES} ${GTEST_LIBRARIES})

Compiling and Running

To compile all tests:

rsmake tests

To run all tests:

rsmake run_tests

To run a single test:

rostest robosub <test>