|
Post by ahartmann on Oct 17, 2013 3:26:08 GMT -5
Hi Martin,
I've wrote my first tests (for a SCI module) and this worked very well.
Now I like to test a second module, which uses functions from this SCI module.
My question is: Should I include this in the existing test or should I create a new one?
For my understanding, it's no problem to have all units in a single executeable, because I can mock every function.
The advantage would be, that I just need to run one executeable to run all tests.
What is your recommendation for this.
Best regards, André
|
|
|
Post by Martin Nielsen on Oct 20, 2013 11:50:06 GMT -5
Hi André
I would say: include SCI code for your new test and keep the function calls to SCI code unmocked (for the majority of the new tests) - Keep the mocks you have already written when you tested the SCI code and use these in the test for the new module. If you need to test special error handling in your new code, based on exit codes from SCI code, then you can choose to mock SCI function calls, however chances are, that you already have a test for the SCI module that you can combine with the new tests for these situations.
I am aware, that I am against one of the mantras within test driven development ( that you should keep your module under tests as small as possible, preferably test on funciton level). It is however my practical experience that doing this, will lead you to tons of tests, but these tests will be without value, if you later need to refactor the code. In fact they will be counterproductive, since you will have to refactor both the test and the code that it is testing.
Therefore I always test at the area of my (our team) resposibillity - e.g. include all those modules that I/(we) am responsible for, and mock the interface for which I/(we) rely on code from others.
This gives me the oppertunity to use the test, if I later want to refactor my code - the tests will then help me and not work against the refactor.
Br, Martin
|
|
|
Post by ahartmann on Oct 20, 2013 13:01:17 GMT -5
Hi Martin,
Thanks for your tips.
I hoped you give this recommendation, because this makes it easier for me to control the build and run process. And in case I want to debug a test, there's only one executeable.
I will try to develop things into this direction the next time.
Best regards, André
PS: The documentation is best of breed! I printed it out for reference and everytime I look into it I find somenthing new interesting...
|
|