It's amazing how little mention of mock objects there are in this discussion. People seem to think that the only reason to avoid hitting a real database is the performance of the test suite. Somebody mentioned avaiability of the database (or other resource) as another issue, which is an excellent point. But one of the best reasons to use mocks instead of the real thing is that it's much easier to simulate certain runtime behavior (i.e., exceptions) using mocks, and ensure that your method under test handles it correctly.
If you really think your existing unit tests are doing a good job while hitting a real database, run them through a code coverage tool like Clover, Cobertura, or EMMA. You'll probably see that little if any of your exception handling code is ever tested.
Flat View: This topic has 50 replies
on 51 pages
[
«
|
212223242526272829
|
»
]