tests) is like doing aerial gymnastics without a net.” [1] The later you detect a bug, the more expensive is to fix it: A bug detected in production may be REALLY expensive Let alone if tomorrow you have a demo!
design better code Faster incremental upgrades A clear metric of your progress It lets you refactor with greater confidence Prevents recurring bugs It enables you to blame others! Other people can work with your code more easily
with any of the following: ./my_test_file make test # needs macro in CMakeLists.txt rosmake <package_name> -t # needs macro in CMakeLists.txt http://wiki.ros.org/gtest Gtest and rostest
syntax with added <test> tag executed with any of the following: rostest <pgk_name> <test_name>.test make test # needs macro in CMakeLists.txt rosmake <package_name> -t # needs macro in CMakeLists.txt http://wiki.ros.org/rostest http://wiki.ros.org/rostest/Writing http://wiki.ros.org/roslaunch/XML/test <------ <test> tag reference
from being built by "make all" rosbuild_add_executable(test_mynode EXCLUDE_FROM_ALL src/test/test_mynode.cpp) # Link test_mynode against gtest # and add a dependency to the "test" target rosbuild_add_gtest_build_flags(test_mynode) # Make sure rostest launches test/mynode.test during "make test" rosbuild_add_rostest(test/mynode.test)
be broken (or that there is no solution): System calls Hardware failures Modules from which your code depends on: Standard Libraries, modules written by others, etc. They already have (or should have) their own tests Exhaustive tests
component in isolation Dependencies between components Some components might be on the network (eg. sockets) Some components might needuser input Some comopnents might just be slow to test
Independent 1. You do not need to read other tests to understand what a test does 2. If a test fails, it should be easy to find the bug 3. Each test focuses on a single aspect Repetible Quick: Use mocks Small: Enables you to easily spot bugs. Big tests functions have many parts affecting each other
any number 2. Factorial calculates factorial of counter 3. Test the library, node and integration using gtest + rostests counter_node factorial_node /counter /factorial /do_increment
Attribution 4.0 International You are free to use and adapt this presentation as long as you give credit to the author. More information can be found here: http://creativecommons.org/licenses/by/4.0/