Run/Debug unity unit tests with QEMU
Posted: Sun Dec 07, 2025 7:58 am
Hi all,
I guess it's a common question here, and I've seen other people asking it before, but I can't seem to find an answer: How can I run and debug the unit tests in a ESP-IDF project?
I've installed ESP-IDF via the manual procedure at https://docs.espressif.com/projects/esp ... setup.html (because I've got a Macbook Pro M3). Then, as suggested in several places, I've copied and compiled the `unit_test` application, which contains unit tests written with Unity:
The project compiles without errors, and I can debug it beautifully.
But:
When running the tests I get an error:
- Error: `The component 'perfmon' could not be found.`
- Hint: `Please look out for component in 'https://components.espressif.com'`
I am not surprised to have errors because, how the project at $IDF_PATH/tools/unit_test_app is going to find my own project? Shouldn't I try to run the test application in my project instead? But how?
I guess it's a common question here, and I've seen other people asking it before, but I can't seem to find an answer: How can I run and debug the unit tests in a ESP-IDF project?
I've installed ESP-IDF via the manual procedure at https://docs.espressif.com/projects/esp ... setup.html (because I've got a Macbook Pro M3). Then, as suggested in several places, I've copied and compiled the `unit_test` application, which contains unit tests written with Unity:
Code: Select all
cp -r $IDF_PATH/examples/system/unit_test .
cd unit_test
idf.py set-target esp32c3
idf.py build
idf.py qemu gdb
But:
- How can I do the same with the component tests? In this example project, they're placed in `unit_test/components/testable/tests`?
- How can I do the same with the test application? In this example project it is placed in `unit_test/test/main/example_unit_test_test.c`
Code: Select all
cd $IDF_PATH/tools/unit-test-app # This proves that $IDF_PATH is correctly defined.
idf.py set-target esp32c3 # No errors here.
idf.py build # No errors here.
idf.py menuconfig # It opens the menu, although I'm not sure what to do with it. I close it with `S`
idf.py -T all build # I get an error here
- Error: `The component 'perfmon' could not be found.`
- Hint: `Please look out for component in 'https://components.espressif.com'`
I am not surprised to have errors because, how the project at $IDF_PATH/tools/unit_test_app is going to find my own project? Shouldn't I try to run the test application in my project instead? But how?