Open jrepp opened 2 years ago
I added some test cases in https://github.com/AprilRobotics/apriltag/pull/314 to check that we still achieve the same detections after changes.
This does not cover all variations of input and therefore something like https://github.com/AprilRobotics/apriltag/issues/72 can still happen on new data if the input is not checked properly. If you are up for it, adding unit tests for individual functions would be appreciated.
I'd like to share a small project I did recently to add automated testing and code coverage to an old GitHub project. In this case the author had archived their project so I forked the project and added the testing capabilities and API extensions.
https://github.com/jrepp/vec/blob/master/.github/workflows/cmake.yml
These workflow actions can be added through the 'Actions' tab by selecting CMake. A matrix build can be configured which allows automating the matrix of the platform, compiler, and library combination.
You can see some sample output here: https://github.com/jrepp/vec/runs/5238299537?check_suite_focus=true
Using
gcov
+gcovr
you get automated coverage analysis of your tests through https://about.codecov.io/. gcov is the standardized tool and gcovr is a nice python wrapper that automates a lot of the command line arguments and reporting.In this case, I was upgrading an existing library that had a test case. The test macros were actually very simple and easy to use.
You can see the CMake configuration here: https://github.com/jrepp/vec/blob/bda7a5da6f1650f6cd4a6f43e73cbb3c30c70e74/CMakeLists.txt#L56
What I do for more complex projects C/C++ (like AprilTag) is that I create multiple CTest targets using uTest (a header-only testing framework) https://github.com/sheredom/utest.h
Pros: you get small executables, if your test crashes it's in an isolated executable and easier to isolate and reproduce Cons: slightly longer build times
With a test/ directory and a CMakeLists.txt file in that directory you can create multiple test executables using a macro like this (cribbed from an embedded network test suite I'm working on):
There are some unique challenges to automated testing of AT. I'm excited to see where this effort leads.