esp-idf/tools/unit-test-app
2023-11-06 17:09:31 +08:00
..
components/test_utils refactor(gptimer): refactor gptimer driver into a component 2023-11-06 17:09:31 +08:00
configs ci: remove ttfw related files 2023-10-16 10:23:09 +02:00
main Build & config: Remove the "make" build system 2021-11-10 09:53:53 +01:00
tools ci: remove ttfw related files 2023-10-16 10:23:09 +02:00
CMakeLists.txt cxx: removed cxx experimental components 2023-01-25 12:34:58 +01:00
idf_ext.py style: format python files with isort and double-quote-string-fixer 2021-01-26 10:49:01 +08:00
partition_table_unit_test_app_2m.csv esp_mm: new virtual memory mapping apis via mmu 2023-02-07 20:23:52 +08:00
partition_table_unit_test_app.csv NVS: using esp_partition API 2020-09-14 10:34:34 +08:00
partition_table_unit_test_two_ota_2m.csv ci: add ut configs for ESP32-C2 2022-06-02 11:10:29 +08:00
partition_table_unit_test_two_ota.csv Whitespace: Automated whitespace fixes (large commit) 2020-11-11 07:36:35 +00:00
README.md ci: remove ttfw related files 2023-10-16 10:23:09 +02:00
sdkconfig.defaults ci(build): fixed/ignored warnings from unknown symbols in sdkconfig.defaults 2023-11-01 01:14:00 +00:00
sdkconfig.defaults.esp32 ci: fix invalid kconfig options in system test apps 2023-05-09 11:27:55 +08:00
sdkconfig.defaults.esp32c2 vfs, spi_flash: re-enable unit tests for C2 2022-10-12 11:09:36 +02:00
sdkconfig.defaults.esp32c3 example_tests: Deletes usage esp32c3 ECO0 in CI (by default ECO3) 2021-09-24 13:55:07 +08:00
sdkconfig.defaults.esp32s2 ulp: migrate tests to pytest embedded 2022-08-03 09:36:17 +08:00
sdkconfig.defaults.esp32s3 ulp: migrate tests to pytest embedded 2022-08-03 09:36:17 +08:00

Unit Test App

ESP-IDF unit tests are run using Unit Test App. The app can be built with the unit tests for a specific component. Unit tests are in test subdirectories of respective components.

Building Unit Test App

CMake

  • Follow the setup instructions in the top-level esp-idf README.
  • Set IDF_PATH environment variable to point to the path to the esp-idf top-level directory.
  • Change into tools/unit-test-app directory
  • idf.py menuconfig to configure the Unit Test App.
  • idf.py -T <component> -T <component> ... build with component set to names of the components to be included in the test app. Or idf.py -T all build to build the test app with all the tests for components having test subdirectory.
  • Follow the printed instructions to flash, or run idf.py -p PORT flash.
  • Unit test have a few preset sdkconfigs. It provides command idf.py ut-clean-config_name and idf.py ut-build-config_name (where config_name is the file name under unit-test-app/configs folder) to build with preset configs. For example, you can use idf.py -T all ut-build-default to build with config file unit-test-app/configs/default. Built binary for this config will be copied to unit-test-app/output/config_name folder.
  • You may extract the test cases presented in the built elf file by calling ElfUnitTestParser.py <your_elf>.

Flash Size

The unit test partition table assumes a 4MB flash size. When testing -T all, this additional factory app partition size is required.

If building unit tests to run on a smaller flash size, edit partition_table_unit_tests_app.csv and use -T <component> <component> ... or instead of -T all tests don't fit in a smaller factory app partition (exact size will depend on configured options).

Running Unit Tests

The unit test loader will prompt by showing a menu of available tests to run:

  • Type a number to run a single test.
  • * to run all tests.
  • [tagname] to run tests with "tag"
  • ![tagname] to run tests without "tag" (![ignore] is very useful as it runs all CI-enabled tests.)
  • "test name here" to run test with given name

Testing Unit Tests with CI

For now we prefer to use component-based unit test to test in CI. Running unit-test-app in CI is being deprecated.