I've spoken before about the limits of test driven design. TDD works well up to a point but there are cases where Test Driven Design is difficult to use to develop parts of your software. One such case I've run into is the problem of setting up an appropriate environment for the test. Even if you're testing only one method, that method may need to talk to other objects to get its work done. For those other objects, you could use mocks or stubs to simulate the real objects but then you're not testing in the real environment and your test is making assumptions or simplifications about how that environment works. The real environment may not match the assumptions in your tests. The best tests are ones that use real objects. The problem then is that you may need to build larger and larger networks of objects just to support the tests. The problem of setting up the environment becomes overwhelming. I usually find that higher level tests are easier to write in these cases than low level tests but this breaks the philosophy of TDD.
Download