Context: unit testing with ceedling System: Windows PC, ceddling builds to .exe file Problem: how to stub a function "MyFunc()" in the same file.c your testing Solution: 1. Create a duplicate function in my test_file.c 2. Use -allow-multiple-definition 3. First instance of function should be taken (test_file.o due to linking order) - Therefore overriding the original Problem: - MAP file shows "MyFunc()" is being used from test_file.c => GOOD - EXE file has both versions of "MyFunc()" and is executing the one from "file.c" => BAD Questions: a) Why does the MAP file not match the EXE b) Are there any compiler/linker flags I can use to resolve this problem Source code: file.c ------------------------------------------------- #include int MyFunc(void) { return 3; } int MyApplication(void) { if ( MyFunc() == 3 ) return 7; else return 12; } test_file.c ------------------------------------------------- #include "unity.h" extern int MyApplication(void); int myfunc_return_value = 0; int MyFunc(void) // stub replacing real function { return myfunc_return_value; } int test_MyApplication(void) { int result = 0; myfunc_return_value = 3; result = MyApplication() TEST_ASSERT_EQUAL_INT(7, result) myfunc_return_value = 1; result = MyApplication() TEST_ASSERT_EQUAL_INT(12, result) } Chris Abbott Firmware Engineer