Unit testing in MRPT

keyboard-bug-001Each of MRPT’s libraries (see list) have its own benchmark of tests to verify and assure that each class of function behaves as expected. For doing so, MRPT uses Google’s gtest unit testing library (read more on the concept of unit testing in this article on Wikipedia).

The mechanism to add new tests is fairly simple, since the CMake scripts worry of recognizing all those source files that implement tests (as explained here) and put them out of the normal MRPT libraries into other special programs which are automatically executed upon testing. As a result, under Visual Studio users can test the correct behavior of MRPT by issuing a “build” command on the target “test”. On Unix/Linux/MacOS the same is achieved issuing a make test command.

Currently, there are more than 100 tests covering aspects from elemental matrix operations to executions of complex SLAM algorithms with predefined datasets, in many cases using randomized data and several input datasets for each test. In all cases, the results are compared to the expected values and errors are reported upon mismatches. Naturally, tests are not always 100% effective and some bugs may still exists, even in unit tested-code, but the chances than future changes break something are greatly reduced thanks to those tests.

It’s also important to note that MRPT builds in Debian/Fedora/Ubuntu repositories, as well as binaries for Windows, are always tested prior to release in order to assure they work as expected. So, there’re reasonable warranties of stable distributions to always work properly, but we’re always improving them and adding more tests with each MRPT version.