Testing static functions with ztest #87442
Unanswered
ovyl-dave-sabol
asked this question in
Q&A
Replies: 1 comment
-
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, of adding ifdef to removing the static keyword while running under test.
The |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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