Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit testing with ESP-IDF

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:

  • I work under Windows and have a MSYS32 shell.
  • My IDF_PATH points to ~/esp-idf, where my esp-idf suite sits.
  • My projects sit in ~/project_dir/subdir, however. They work as they should.

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:

  • Should I add the project paths somewhere into the unit test app?
  • Should I copy the unit test app and add it to my projects?
  • Should I create a folder in my project and add a link to the unit test app?
like image 463
glglgl Avatar asked Jul 04 '18 15:07

glglgl


People also ask

Can unit tests use databases?

To test an application it is not enough to use unit tests. You must also perform functional testing and regression testing. Database access falls outside the scope of unit testing, so you would not write unit tests that include database access.

What is unit testing in SAS?

Unit testing frameworks control the execution of test scenarios and generate test reports. SASUnit is a unit testing framework for SAS programs and SAS macros and is itself implemented as a SAS macro package.

What is ESP-IDF framework?

ESP-IDF is Espressif's official IoT Development Framework for the ESP32, ESP32-S, ESP32-C and ESP32-H series of SoCs. It provides a self-sufficient SDK for any generic application development on these platforms, using programming languages such as C and C++.

What is angular unit testing?

Angular Unit testing is the process of testing small and isolated pieces of code in your Angular application. This provides an added advantage to the users in the sense that they can add any new features without breaking any other part of their application.


1 Answers

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
like image 77
detly Avatar answered Sep 25 '22 18:09

detly