-
Notifications
You must be signed in to change notification settings - Fork 250
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
Mock only some specific functions in the same file (partial mocking) #936
Comments
:) What you are describing here is very close to how |
This is great news!! |
Sadly at the moment it exists only as a collection of files on my personal repo. It's staged to get added to the next release when some things are worked out. |
ok thanks for the info. |
Not that I am aware of. As far as I know, we'd be the first... and that makes me excited to work on it. :) |
In my opinion this will be one of the features of CMock/Ceedling that will make it stand out from the crowd. |
I like the idea very much! MOCK_STATIC_FUNCTIONS(); |
For legacy codebases this feature will be essential as re-organising an entire codebase to introduce a testing framework is unlikely to fly due to the risk of having to revalidate the entirety of the software. |
I know this topic has been discussed at length, and several workaround have already been presented, but none of the existing solutions satisfy me fully, and I think Ceedling can do better(?) (although I am not sure that my proposal is feasible).
The workaround that is usually proposed is to move the static functions into private helper file and include it in the main file, so the helper file can be tested separately, and then use the "mocked version" of the helper file when you want to test the main file.
But sometimes this is not possible for example when working with legacy code, also if a helper function calls another helper function I have to separate these functions into different files (which I don't like at all), and in any case sometimes I want to keep my static functions in the main file because it makes sense according to the design of my application.
I would like to propose the following solution:
Basically
INCLUDE_SOURCE("file_name.c")
tells Ceedling to copy the filefile_name.c
intobuild/test/original_src/src_<file_name>.c
, so theoriginal_src
folder should contain a copy of the original source files from which only the functions specified by theMOCK_FUNCTION("function_name")
macros need to be removed.This eliminates function redefinition errors during compilation and linking.
Would it be possible to implement something like this in Ceedling?
The text was updated successfully, but these errors were encountered: