Currently, I am working with an ESP-IDF and try to get unit testing to work.
I already found https://esp-idf.readthedocs.io/en/latest/api-guides/unit-tests.html, but there is a point which I don't understand.
But first, let me explain my setup:
IDF_PATH
points to ~/esp-idf, where my esp-idf suite sits.If I follow the instructions in the unit test guides, I can build the test cases which are built into the system. But it does not find the unit tests of my application. This is clear, as they sit somewhere completely else.
What am I supposed to do now? Perferrably without tampering with the default unit test app too much?
I can see several approaches, but I don't know what is the intended way to add own components resp. their test cases into the said app:
The ESP-IDF unit test setup is actually designed for testing its own internal components, and to help anyone adding to those.
To unit test your own project separately, take a look at this example project that shows how to create a Unity unit test application alongside a proper project. Note that the project itself is called unit_test
, so the test application is unit_test_test
. The component is called testable
. (I'm flagging that because it confused me; interpret unit_test
like you might read example_app
or myproject
.)
Failing that, this ESP forum post also gives a way to include your components in their unit test app:
make -C ${IDF_PATH}/tools/unit-test-app EXTRA_COMPONENT_DIRS=/path/to/my_proj/components TEST_COMPONENTS=mycomponent