It is necessary to maintain real code. There are assumptions in real code that have not been well documented. This code has been modified by people who forget or never know these assumptions. Trust the test, do not trust the code.
Real TDD allows you to create an object and its methods before implementation. You need a clear model before you can write a test case.
So, generate object (s), add methods, parameters, etc. Perhaps using UML2 would be better, then write test cases for them, and then implement the objects. After that, run the profiler and find out how terrible your code and refactoring is.
As a general solution, it is almost always better to write a factory object to create and initialize your objects. The closer you get to the core functionality, the more it becomes important.
Write tests for expected failures and exceptions. use validation to make sure.
Finally, write each test and see how it works before writing code to make it successful.
source share