The second and last question in my current series of questions about TDD and unit tests...
For the purpose of this question, a 'unit test' is defined as a test that focuses only on a particular method and that mocks all dependencies of the class of this method. (As opposed to any other sort of automatic test, such as an integration test or any test that does not mock dependencies). TDD is defined as a cycle when I write a unit test, the smallest test that is necessary to write for it to fail, then I write some production code, again the smallest bit that is necessary for the test to pass, then I refactor.
I've always dreaded unit tests and TDD. The reason is that I tried this methodology once in my life, and my productivity, as a result, nosedived to almost zero.
I then learned there was also another approach to testing, one that preferred tests at a higher level of integration and avoided mocks. I thought this was the answer. I thought that unit testing and TDD were hostile to productivity because of the tremendous overhead they incurred; also they forced an architecture that was proliferating with lots and lots of tiny classes, functions, abstractions etc, again incurring overhead.
It appears that, to my great fear, I am now actually forced to write unit tests. I am told I must cover all my code by unit tests that mock dependencies. Mocking dependencies is required. Rigorous TDD is expected to be enforced at an unspecified future.
To be frank: I fear that I will soon become unable to write any code, because of the tremendous overhead of adhering to TDD and requirement to cover all code I write by unit tests (with an emphasis on unit).
How do I write lots and lots and lots of unit tests while remaining productive?