Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create a test file

    1. Inside AutoPilot/Test/Src/**Some_Directory_for_classification**, create a Test_YOURMODULENAME.cpp file.

    2. To get started, at the minimum, you’l you’ll need

      Code Block
      languagecpp
      #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.

  2. Tell Cmake about your file.

    1. Open AutoPilot/CmakeLists.txt and scroll down to the unit testing section.

    2. In the include_directories section, make sure the path to the directory containing YOURMODULENAME.hpp is there. If it isn’t, add it.

    3. 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).

      1. 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

      2. 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.

    4. 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.

...