13 Jun 2014, 15:44
Generic-user-small

Joao Ferreira (2 posts)

Hi.

I have a (maybe) dumb question. On MockIO.c there is a IO_Write function that (I think) replaces the original one implemented on IO.c.

I don’t really understand where in the make process this happens.

Can someone enlight me?

Also it would be good to have a detailed presentation about how the makefiles are set up. At the moment I feel that the ‘code’ folder is a bit of a mess.

22 Jun 2014, 01:38
Generic-user-small

Richard Hagberg (10 posts)

Joao,

If you look in 8.3 Link-Time Substitution in the book, James talks about Link-Time Substitution. In appendix A1.2, James talks about the need to use makefiles to perform link-Time substitution. I am pretty sure this is what he is doing in the MockIO tests to get the mock IO_Write function to override the IO_Write which is already created in IO.c. Between these two parts of the book, I get the feeling that you need a makefile to do this.

23 Jun 2014, 15:37
Generic-user-small

Joao Ferreira (2 posts)

Hey thanks for your reply.

I have the same feeling. I only wish that the makefile creation was explained a bit better.

I understand that it is not the main scope of the book, however I feel that is one of the hardest part. The trouble of setting up an environment to develop using the test-driven approach is driving me a bit crazy.

Maybe the appendices could be a bit more in-depth. Do you have any suggestion where I can dig more information?

23 Jun 2014, 19:08
Generic-user-small

Richard Hagberg (10 posts)

In doing a little more playing around, I have found out that at least in Visual Studio, as long as you set up the production code project as a library and the tests as a console application project, it will use the spies and mocks created in the test project before the original functions in the production code library. You need to make sure to set the solution settings so that the library is compiled first and then the test application. If you have any questions about how to do this or anything else, just respond here and I will do my best to try and answer them. I am still figuring this all out myself, so I might not have all the answers, but am willing to help if I can. Good luck.

  You must be logged in to comment