diff --git a/README.md b/README.md index 8b38915..bfc0a35 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,13 @@
  • Examples
  • +
  • + Unit Tests + +
  • Documentation
  • Program Flowcharts
  • Acknowledgements
  • @@ -190,6 +197,58 @@ extern "C" void app_main(void) ```

    (back to top)

    +## Unit Tests +A basic unit testing suite is included with this library, but it is very rudimentary. +It can be used to verify some of the basic features of a BNO08x device. +

    (back to top)

    + +### Running Tests +1. Create a project and add the component as described in the getting started guide. + + +2. Open the outermost CMakeLists.txt file in the project root directory, as depicted below. + + ![image](README_images/OutermostCMake.png) + +3. Modify the file by adding "set(TEST_COMPONENTS "esp32_BNO08x" CACHE STRING "Components to test.")" as depicted below: + + ```cmake + # For more information about build system see + # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html + # The following five lines of boilerplate have to be in your project's + # CMakeLists in this exact order for cmake to work correctly + cmake_minimum_required(VERSION 3.16) + add_compile_definitions("ESP32C3_IMU_CONFIG") + set(TEST_COMPONENTS "esp32_BNO08x" CACHE STRING "Components to test.") + include($ENV{IDF_PATH}/tools/cmake/project.cmake) + project(bno08x_update) + ``` + +4. Include the test suite in your main file and launch into the test suite: + + ```cpp + #include + #include "BNO08xTestSuite.hpp" + + extern "C" void app_main(void) + { + BNO08xTestSuite::run_all_tests(); + } + ``` + +5. Ensure you run `idf.py fullclean` or delete your build directory before building for the first time after modifying the CMakeLists.txt file in step 3. + +

    (back to top)

    + +### Adding Tests +Tests are implemented with the [esp-idf unity unit testing component](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/unit-tests.html). + +To add a test, create a new .cpp file, or modify one of the existing ones in `esp32_BNO08x/test/()`. +Follow the existing test structure as an example, use the `TEST_CASE(){}` macro. + +Any tests added will automatically be detected at build time. +

    (back to top)

    + ## Documentation API documentation generated with doxygen can be found in the documentation directory of the master branch.

    (back to top)

    diff --git a/README_images/OutermostCMake.png b/README_images/OutermostCMake.png new file mode 100644 index 0000000..2daac3f Binary files /dev/null and b/README_images/OutermostCMake.png differ