Making and running tests with ros.

Documentation is not super clear on how to run tests.

nosetests are python tests, and are wrappers around unittest.

Build the tests of a particular package:

catkin_make image_geometry tests
catkin_make run_tests_image_geometry_nosetests
Base path: /home/lucasw/catkin_ws
Source space: /home/lucasw/catkin_ws/src
Build space: /home/lucasw/catkin_ws/build
Devel space: /home/lucasw/catkin_ws/devel
Install space: /home/lucasw/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/lucasw/catkin_ws/build"
####
####
#### Running command: "make run_tests_image_geometry_nosetests -j4 -l4" in "/home/lucasw/catkin_ws/build"
####
Scanning dependencies of target run_tests_image_geometry_nosetests_directed.py
-- run_tests.py: execute commands
  /usr/bin/cmake -E make_directory /home/lucasw/catkin_ws/build/test_results/image_geometry
  /usr/bin/nosetests-2.7 -P --process-timeout=60 /home/lucasw/catkin_ws/src/vision_opencv/image_geometry/test/directed.py --with-xunit --xunit-file=/home/lucasw/catkin_ws/build/test_results/image_geometry/nosetests-directed.py.xml
..
----------------------------------------------------------------------
Ran 2 tests in 0.017s

OK
-- run_tests.py: verify result "/home/lucasw/catkin_ws/build/test_results/image_geometry/nosetests-directed.py.xml"
Built target run_tests_image_geometry_nosetests_directed.py
Scanning dependencies of target run_tests_image_geometry_nosetests
Built target run_tests_image_geometry_nosetests
$ catkin_make run_tests_image_geometry
Base path: /home/lucasw/catkin_ws
Source space: /home/lucasw/catkin_ws/src
Build space: /home/lucasw/catkin_ws/build
Devel space: /home/lucasw/catkin_ws/devel
Install space: /home/lucasw/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/lucasw/catkin_ws/build"
####
####
#### Running command: "make run_tests_image_geometry -j4 -l4" in "/home/lucasw/catkin_ws/build"
####
[  0%] [  0%] Built target sensor_msgs_generate_messages_cpp
Built target geometry_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_cpp
[  0%] Built target std_msgs_generate_messages_eus
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_py
-- run_tests.py: execute commands
  /usr/bin/cmake -E make_directory /home/lucasw/catkin_ws/build/test_results/image_geometry
  /usr/bin/nosetests-2.7 -P --process-timeout=60 /home/lucasw/catkin_ws/src/vision_opencv/image_geometry/test/directed.py --with-xunit --xunit-file=/home/lucasw/catkin_ws/build/test_results/image_geometry/nosetests-directed.py.xml
[  0%] Built target sensor_msgs_generate_messages_py
[  0%] Built target geometry_msgs_generate_messages_cpp
[  0%] Built target sensor_msgs_generate_messages_eus
[  0%] Built target sensor_msgs_generate_messages_lisp
[  0%] Built target geometry_msgs_generate_messages_py
[  0%] [  0%] Built target gtest
Built target geometry_msgs_generate_messages_eus
[  0%] Built target gtest_main
[  0%] Built target image_geometry
[100%] Built target image_geometry-utest
Scanning dependencies of target run_tests_image_geometry_gtest_image_geometry-utest
-- run_tests.py: execute commands
  /home/lucasw/catkin_ws/devel/lib/image_geometry/image_geometry-utest --gtest_output=xml:/home/lucasw/catkin_ws/build/test_results/image_geometry/gtest-image_geometry-utest.xml
[==========] Running 5 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 5 tests from PinholeTest
[ RUN      ] PinholeTest.accessorsCorrect
[       OK ] PinholeTest.accessorsCorrect (0 ms)
[ RUN      ] PinholeTest.projectPoint
[       OK ] PinholeTest.projectPoint (1 ms)
[ RUN      ] PinholeTest.rectifyPoint
[       OK ] PinholeTest.rectifyPoint (65 ms)
[ RUN      ] PinholeTest.getDeltas
[       OK ] PinholeTest.getDeltas (0 ms)
[ RUN      ] PinholeTest.initialization
[       OK ] PinholeTest.initialization (0 ms)
[----------] 5 tests from PinholeTest (66 ms total)

[----------] Global test environment tear-down
[==========] 5 tests from 1 test case ran. (66 ms total)
[  PASSED  ] 5 tests.
-- run_tests.py: verify result "/home/lucasw/catkin_ws/build/test_results/image_geometry/gtest-image_geometry-utest.xml"
[100%] Built target run_tests_image_geometry_gtest_image_geometry-utest
Scanning dependencies of target run_tests_image_geometry_gtest
[100%] Built target run_tests_image_geometry_gtest
..
----------------------------------------------------------------------
Ran 2 tests in 0.015s

OK
-- run_tests.py: verify result "/home/lucasw/catkin_ws/build/test_results/image_geometry/nosetests-directed.py.xml"
[100%] Built target run_tests_image_geometry_nosetests_directed.py
[100%] Built target run_tests_image_geometry_nosetests
Scanning dependencies of target run_tests_image_geometry
[100%] Built target run_tests_image_geometry

Trying to connect to running rostest

In first terminal:

rostest src/image_pipeline/image_proc/test/test_rectify.xml

in second terminal:

export ROS_MASTER_URI=http://127.0.0.1:22422
rostopic list
ERROR: Unable to communicate with master!

The test runs for about 60s then quits in failure.

Put a test into testbot and try again, also on different computer.

Written on March 2, 2016