Unit testing ESP-IDF components with GoogleTest (host-based)
I had been looking for a way to test ESP-IDF component logic without flashing to the board every time. The cycle of edit, flash, read serial gets old fast, especially when the bug is just in a calculation or a state machine — nothing hardware-specific. ESP-IDF supports building for a Linux target, which means you can run tests straight on your machine. I put together a repo to document how I set this up, using GoogleTest as the test framework. This post covers the first example: aluiziotomazelli/gtest-esp-idf . Prerequisites To run these tests you need ESP-IDF 5.x installed and sourced, a Linux machine or WSL2, and two system packages that the IDF linux target depends on: sudo apt install libbsd0 libbsd-dev If you use the official ESP-IDF Docker container ( idf-env latest), these are already included and you can skip this step — the CI badges on the repo run exactly that way, with no extra setup. Ruby is not needed for this example. It only comes in when using CMock-based IDF mocks, wh
Continue reading on Dev.to
Opens in a new tab

