I am very skeptical about writing unit tests before implementation. Maybe it would be effective if you had a good idea of the exact design of the classes and methods, but usually you do not do this at the beginning of a new project.
My preferred approach is to admit that starting a new project can be a bit of organized chaos. One part of the design process is writing code to test certain ideas or find the best way. For a long time, the code gets stuck and is discarded, and any unit tests written for it would be a waste of time.
Do not misunderstand me. I'm all for well-designed software, and at some point it is important that organized chaos turn into a well-understood design. At this point, the class structure and UML diagrams begin to solidify. This TDD point is becoming important to me. Each class must be tested in isolation. If the design is good with the right degree of isolation, which is usually easy to achieve by spraying piece objects around the site. If the design of poor testing becomes a real nightmare and, therefore, it is ignored.
At the end of the day, this is the quality productive code that you need. Unit tests are one of the best tools to achieve this, but they should not take on life and become more important than the ones they experience that you sometimes feel from the TDD mantra.
source share