But then I go back and add an integration test(or tests) that set up the appropriate environment for the External Bits and validate that the combination of my code and the External dependencies all work as advertised. Both sets of tests have to pass before I have a 'Clean Run'(tm) of my test-harness.
In the process of setting up the integration test, I may find that External Bit phoo has a dependency on another External Bit baht, so I mock that dependency and roll forward writing my test.
Once I have a clean unit+integration test, my level 1 test harness; I build build a level 2 integration test, replacing the mocked baht dependency with baht itself and write the integration tests for that. Rinse and repeat, until I have worked myself up to the top of the stack.
Yes it is a LOT of work. But, the first time that your test-harness fails because someone made a 'minor change' change four levels up the stack -- it's worth every hard fought second. And that's the real utility of a Test-Harness. When Someone makes a change, I get early warning of any issues before the Code reaches the User. Testing in depth and nightly cycles are the way to go.
----
I Go Back to Sleep, Now.
OGB
In reply to Re: Testing: To Mock or Not to Mock?
by Old_Gray_Bear
in thread Testing: To Mock or Not to Mock?
by agianni
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |