Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests for esp-idf wrapper components #101

Open
Barabas5532 opened this issue Dec 14, 2023 · 0 comments
Open

Unit tests for esp-idf wrapper components #101

Barabas5532 opened this issue Dec 14, 2023 · 0 comments

Comments

@Barabas5532
Copy link
Member

Most ESP-IDF APIs are written in C, so googletest can't be used to mock them. We have to use link time substitution to mock the C APIs. Some options:

  • Wrap up the C API in a C++ API which can be mocked with googletest. This would be tightly coupled to the low level ESP-IDF component, unlike the wrapper which abstract ESP-IDF away. Then we can test the higher layer by mocking this low level wrapper. Even if we did this, then we might want to test the low level wrapper in some way, so this is not a solution.
  • https://github.com/meekrosoft/fff to mock the methods. The mock generation macros don't work in C++, and if used with C, then we can't easily test the wrapper's API which is C++.
  • https://cpputest.github.io/ seems easy enough, just have to use link time substitution on the C API
  • http://www.throwtheswitch.org/ceedling automates generating the mock C functions and also includes methods to set up expectations on calls. Might be easier to get going than cpputest.

https://stackoverflow.com/questions/14233853/c-unit-testing-and-stubbing-a-3rd-party-c-library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant