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

Is it possible to mock static functions? #106

Open
KasperZK opened this issue Nov 22, 2021 · 1 comment
Open

Is it possible to mock static functions? #106

KasperZK opened this issue Nov 22, 2021 · 1 comment

Comments

@KasperZK
Copy link

I presented the framework to my team and it raised some questions:

Can you mock static functions with this framework? For example would it be possible to mock and test a static function that is both defined and declared in the .c file that is to be tested? Do we even want to do this ever or should private functions only be accessed through public functions?

Thanks

@nradulovic
Copy link

nradulovic commented Nov 22, 2021

Hi, you can only mock functions which are defined outside of tested implementation unit (.c).

In my projects I treat static functions as part of tested function so I don't need to mock them. When I get into the situation that I need to mock a static function, then that is a sign to me that I need to re-think about architecture of the code and ask some questions to myself.

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

2 participants