Open parmi93 opened 6 days ago
:) What you are describing here is very close to how scalpel
works, which is a new CMock feature. It's currently under development, but likely going to be the release after the soon-to-be-released version.
This is great news!!
Could you please link me something about this scalpel
, I can't find anything on Google about it.
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. As far as you know, are there any unit test frameworks out there that support this feature? looking around it seems like no one supports such a thing
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 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?