This repository has been archived by the owner on Sep 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
How To: Unit Testing
Tyler Gamvrelis edited this page Oct 30, 2018
·
5 revisions
The following steps will ensure that code can be thoroughly tested independent of the hardware it will be running on.
- Add source files that do not depend on any board-specific hardware to Common/component/. For example, Common/component/NewModule/NewInterface.cpp
- Write a test driver file using the GoogleTest/GoogleMock framework add it under Common/test. This file name will be the name of the module or class followed by "_test", e.g. "NewModule_test.cpp" and "NewInterface_test.cpp". Sometimes it is easier to test class-by-class, while other times it is only necessary to test the module. This depends on the complexity of the module and it is left up to the programmer's discretion to do what they think is clear and easy to maintain
- With RobotTest open in Eclipse, navigate to the new source and test files within the linked resources "Common" and uncheck "Exclude resource from build" under Properties->C/C++ Build->Settings for all relevant configurations
- Run the unit tests under all configurations (e.g. Test_F4 and Test_F7) to ensure the new code is portable to all supported hardware options
TODO: tutorial on writing unit tests & brief overview of test-driven development. Also go over how to fake calls to the hardware to test data processing algorithms