...
Create a test file
Inside AutoPilot/Test/Src/**Some_Directory_for_classification**, create a Test_YOURMODULENAME.cpp file.
To get started, at the minimum, you’l you’ll need
Code Block language cpp #include #include <gtest/gtest.h> #include “YOURMODULENAME.h” using namespace std; using ::testing::Test;
Feel free to take a look at the other Test files to see what they consist of.
Tell Cmake about your file.
Open AutoPilot/CmakeLists.txt and scroll down to the unit testing section.
In the include_directories section, make sure the path to the directory containing YOURMODULENAME.hpp is there. If it isn’t, add it.
Keep scrolling down, you’ll see a series of subsections, (######### Attitude manager fsm, for example). Each of those subsections produces a single exe. Figure out whether your module fits within one of those sections or whether you need to create a new subsection (do this by feel, you’ll probably be right).
If it fits within an existing subsection, add your MYMODULE.cpp file to the ***SOURCES variable and add your Test_MYMODULE.cpp file to the ***UNIT_TEST_SOURCES variable
If you make your own subsection, just copy one of the existing subsections, gut all of the existing files and add your stuff the same way as in i, making sure to name the section, the variables and the exe something meaningfullmeaningful.
Your’e done! if you run the build script with -c -t, ( -c only for the first time), it should pull in and execute your tests.
...