unit testing - How to mock function in same UUT in C -


i learning unit testing using ceedling, cmock mocks, on existing, embedded c code-base (which can adjust suit).

i have come across situation 1 function in unit calls second function within same unit.

int foo_a(int r)  {     /* foo_a work */     /* not wish test function test foo_b. */ }  int foo_b(int i) /* function test */ {     /* foo_b work */     if (some_condition)         foo_a(k); /* need test if foo_a() called or not. */ } 

i don't want test foo_a() part of foo_b() tests. how mock foo_a() can still test if called or not without testing foo_a() function itself?

you can't without modifying source code.

consider breaking functions out 2 separate compilation units.

or, add #ifndef test around function want replace.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -