Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

ZP 3 uses gtest for unit testing.

To run unit tests:

You can use the testing/test.bash script.

  • To clean the unit testing build, use ./testing/test.bash clean

  • To build the unit tests, use ./testing/test.bash build

  • To run the built unit tests, use ./testing/test.bash run

  • To only run a certain TestSuite of tests, use ./testing/test.bash run "<Suite regex>:*"

Alternatively, you can use docker to do all of this. Please refer to our How-To on using docker in zp3.

To write unit tests:

unit tests are fairly straight forward, here are some things to remember:

  • read this primer on gtest: http://google.github.io/googletest/primer.html

  • make sure your tests are in <Manager>/tests

  • Any header you include must make no reference of STM32 specific things. The unit tests are built using gcc, which means the code must not be meant for ARM platform.

  • By default, including a header from <Manager>/Inc will work, but if the functions in that header are implemented in a cpp file, it will need to be included in the CMakeLists.txt for testing. An example of that is here: https://github.com/UWARG/ZeroPilot-SW-3/blob/b34d1775bf22d4c90ea2e372442991cd34691a6b/testing/CMakeLists.txt#L39 where CRC32.cpp was added because the tests needed a function that was implemented there. If you have headers that are not in <Manager>/Inc, youll need to add them to CMakeLists, please let me know (SnackOverflowError#0543), I can fix the CmakeLists for you.

  • Test naming: the test macro has 2 name fields. One for the group of tests (TestSuite) and one for the test itself. The TestSuite name should include whatever component is being tested (like TM for telemetry manager), so that the results can be understood, or so that its easier to only test a single component.

    • for example, when testing System manager, the name should be prefixed with SM, so that the user can choose to only run SM tests.

  • No labels