Testing static functions with ztest #87442
Replies: 2 comments
-
I am not sure if there is any correct way to do this, but what I did in net stack is to either have a special test function defined next to where the static function is set, or adding ifdef to removing the static keyword while running under test.
The |
Beta Was this translation helpful? Give feedback.
-
Would you be able to share how you got this working? I've been trying to get Ztest to work with nrf connect SDK 2.6.1 but haven´t found any good solutions. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have ztest set up for unit testing (the actual hardware is based on the nrf9160).
Building and running the unit tests for native posix works well and we have code coverage working.
But we can't figure out how to test static functions. In ceedling we would #include the source file in the test file, but because the source file is in cmakelists.txt, it fails to build. If we don't include the source file in cmakelists.txt we can use a #include of the .c file in the test file and test the static functions that way, but we no longer get code coverage.
What is the correct way to test static functions with z test that still allows code coverage?
Beta Was this translation helpful? Give feedback.
All reactions