This repository was archived by the owner on Jan 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Unit tests
tcies edited this page Oct 21, 2014
·
7 revisions
We ensure the basic level of integrity by automatically building all repositories several times a day and running unit-tests. This can eliminate the following errors:
- General compilation errors caused by syntax errors, missing includes, wrong include paths.
- Missing files that are available locally but not checked into the repo.
- Hardcoded local paths for files required for build-tests.
- Depending on the unit-test coverage, this checks the correct functioning of the software.
We use gtest (install from Ubuntu packages) for unit tests. In catkin and catkin simple, google-tests can be simply added as follows:
catkin_add_gtest(test_xyz test/xyz-test.cc)
target_link_libraries(test_xyz <project libraries>)
If you use catkin build, you can build and run unit tests as follows:
cd catkin_ws/build/<project>
make tests
make run_tests
make run_tests_<project>_gtest_test_xyz
Use the latter to only run the specified test.
- Keep all test-related source code in a folder called
test
in your package root. - Make a separate test file for each class that you test.
- Call the Cmake target
test_class
and the source fileclass-test.cc
(tab-completion VS readability) - For the test case name, use the name of the tested class, suffixed by
Test
- Use the same naming convention for fixtures that are local to the test file
- For fixtures that are shared between different test files, use the suffix
Fixture
instead.
Consider Eigen checks if you are comparing Eigen objects and for a macro for main()
.