I have 3 questions regarding using unit tests that use mocks, and this is a cross post from a thread that I posted on CodePlex. I am curious to see what you guys think.
Question Summary:
-
Is it correct that mocks are just testing the published / public interfaces of the objects that the mock object mimics?
-
Aside from proving that you have invoked the methods and members of your mock classes, how valuable are unit tests that work with mocks? (Afterall the mock code doesnt interact with the "real code")
-
should we be using unit tests that work with the "real" code in addition to unit tests that work with mock objects?
Re-Post of Original Thread
I have been evaluating WCSF for use withing my organization. At my company we use CI and TDD practices and I see the value in unit tests and code coverage analysis, etc. etc. I have never been a real fan of MVP / MVC because of all of the moving parts compared to what "really" gets re-used. A Microsft MVP told me that the "real" purpose of the MVP & MVC patters was to allow us to unit test more of the code and to allow us to switch between WinForms, WebForms, and CompactFramework with minimal modifications to code. So, once again, here I am reviewing the latest and greatest from the P&P team.
In my review of the Global Bank Commercial EBanking solution, I see that mocks are used heavily. I am not too sure if I am missing the point but it seems to me that mocks are just testing the published / public interfaces of the objects being created in WCSF (i.e., views, presenters, controllers, services, module initializers, etc.).
Assuming that this observation is correct, I have concluded that the "real" functionality that is being delivered is never tested with mocks. Is this a correct conclusion? The reason that I have come to this conclusion is that I havent found many unit tests that deal with the "real" code, (i.e. the functional code that lives in the NON-mock classes).
So I guess my real question is this... aside from proving that you have invoked the methods and members of your mock classes, how valuable are unit tests that work with mocks? My reasoning behind this question is that, just because our executing code hits the mock classes, if the code that lives in the real object doesnt work then we dont have functionality that is deliverable.
My second question is this... should we be using unit tests that work with the "real" code in addition to unit tests that work with mock objects?
Thanks for your guidance, opinions, and comments.