Closed MJ-CJM closed 1 year ago
Here is an excerpt from our makefile. The cmock submodule is located in $(UNITTEST_FRAMEWORK)/tools/
. and configuration yaml is passed through CMOCK_CONFIG
. HIDE_CMD
and NO_OUTPUT
can simply be @
and /dev/null
so that we have less printouts.
$(MOCK_COMPONENT_C_FILES):$(SRCDIR)/$(MOCKS_DIR)/%_mock.c: $(SRCDIR)/src/%.h
$(HIDE_CMD)$(MKDIR) $(dir $@)
$(HIDE_CMD)$(RUBY) $(UNITTEST_FRAMEWORK)/tools/cmock/lib/cmock.rb --mock_path=$(MOCKS_DIR) -o$(CMOCK_CONFIG) $< $(NO_OUTPUT)
There are also examples that can help: https://github.com/ThrowTheSwitch/CMock/blob/master/examples/make_example/Makefile
Maybe also https://github.com/ThrowTheSwitch/CMock/issues/389#issuecomment-1085576545 might be helpful if you are looking into non-ceedling path.
Thanks a lot, I'm trying
Thank you very much, I have done the test of the case according to the makefile,In addition, I have tow questions
Can you rephrase your questions?
mock_myfile.h
, and include a real header file (myfile.h
) which will get linker complaining about missing functions, so you need to write bodies of the functions in the file. Secondly, just split out the functions you don't want to mock in another header file and work with it that way.Thank you very much for your reply, I haven't used ceedling yet, but only through unity and cmock to complete the test. Is this also a feasible solution? Are there any good ceedling examples that I can learn from?
Throwtheswitch website is usually a decent starting point: https://www.throwtheswitch.org/ceedling
Otherwise GitHub has some basic examples there as well: https://github.com/ThrowTheSwitch/Ceedling/tree/master/examples
Ceedling basically ties together Unity and Cmock, so that you do not need to write your own build system. It is great for basic and advanced use, the only drawback is that it is written in Ruby in case you will want to implement some new feature.
Please close the issue if it has been resolved.
hi: I already know how cmock work (https://www.throwtheswitch.org/cmock),but i don't know how to uses Ruby scripts to auto-generate C source modules conforming to the interfaces specified in your C header files,Maybe it's my first exposure to ruby,do we have such guidance documents?