Run/Debug unity unit tests with QEMU

jmgonet
Posts: 1
Joined: Thu Nov 20, 2025 4:50 am

Run/Debug unity unit tests with QEMU

Postby jmgonet » 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:

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
The project compiles without errors, and I can debug it beautifully.

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`
I've read the article at https://docs.espressif.com/projects/esp ... tests.html. It starts by describing the same structure as the example program `unit_test`, which is the very one I'm trying to use now. But I can't understand the section https://docs.espressif.com/projects/esp ... t-test-app. Anyway, in a leap of faith, I still try it:

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
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?

Who is online

Users browsing this forum: ChatGPT-User, Qwantbot and 4 guests