@@ -756,19 +756,35 @@ Do the following in directory `Ref/MathSender`:
7567561 . Run ` mkdir -p test/ut ` to create the directory where
757757the unit tests will reside.
758758
759- 1 . Run the command ` fprime-util impl --ut ` .
759+ 2 . Update Ref/MathSender/CMakeLists.txt:
760+ Go back to the directory ` Ref/MathSender ` .
761+ Add the following lines to ` CMakeLists.txt ` :
762+
763+ ``` cmake
764+ # Register the unit test build
765+ set(UT_SOURCE_FILES
766+ "${CMAKE_CURRENT_LIST_DIR}/MathSender.fpp"
767+ )
768+ register_fprime_ut()
769+ ```
770+
771+ This code tells the build system how to build
772+ and run the unit tests.
773+
774+ 4 . Run ` fprime-util generate --ut ` to generate the unit test cache.
775+
776+ 5 . Run the command ` fprime-util impl --ut ` .
760777It should generate files ` Tester.cpp ` and ` Tester.hpp ` .
761778
762- 1 . Move these files to the ` test/ut ` directory:
779+ 6 . Move these files to the ` test/ut ` directory:
763780
764- ``` bash
765- mv Tester.* test/ut
766- ```
781+ ``` bash
782+ mv Tester.* test/ut
783+ ```
767784
768785** Create a stub main.cpp file:**
769786Now go to the directory ` Ref/MathSender/test/ut ` .
770- In that directory, create a file ` main.cpp ` with the
771- following contents:
787+ In that directory, create the file ` main.cpp ` and add the following contents:
772788
773789``` c++
774790#include " Tester.hpp"
@@ -784,23 +800,20 @@ This file is a stub for running tests using the
784800Right now there aren't any tests to run; we will add one
785801in the next section.
786802
787- **Update Ref/MathSender/CMakeLists.txt:**
788- Go back to the directory `Ref/MathSender`.
789- Add the following lines to `CMakeLists.txt`:
803+ 7. Add the new files to the build.
790804
805+ Open `MathSender/CMakeLists.txt` and modify the `UT_SOURCE_FILES` by adding
806+ your new test files:
791807```cmake
792808# Register the unit test build
793809set(UT_SOURCE_FILES
794810 "${CMAKE_CURRENT_LIST_DIR}/MathSender.fpp"
795- "${CMAKE_CURRENT_LIST_DIR}/test/ut/Tester.cpp"
796811 "${CMAKE_CURRENT_LIST_DIR}/test/ut/main.cpp"
812+ "${CMAKE_CURRENT_LIST_DIR}/test/ut/Tester.cpp"
797813)
798814register_fprime_ut()
799815```
800816
801- This code tells the build system how to build
802- and run the unit tests.
803-
804817** Run the build:**
805818Now we can check that the unit test build is working.
806819
0 commit comments