I am new to test-driven development, but I'm loving it. There is, however, a main problem that prevents me from using it effectively.
I work for embedded medical applications, plain C, with safety issues.
Suppose you have module A
that has a function A_function()
that I want to test. This function call a function B_function
, implemented in module B
.
I want to decouple the module so, as James Grenning teaches, I create a Mock module B
that implements a mock version of B_function
.
However the day comes when I have to implement module B
with the real version of B_function
. Of course the two B_function
can not live in the same executable, so I don't know how to have a unique "launcher" to test both modules.
James Grenning way out is to replace, in module A
, the call to B_function
with a function pointer that can have the value of the mock or the real function according to the need.
However I work in a team, and I can not justify this decision that would make no sense if it were not for the test, and no one asked me explicitly to use test-driven approach.
Maybe the only way out is to generate different a executable for each module.
Any smarter solution? Thank you