If the code can be fully generated, then the basis of the generator should be a specification that accurately describes the code. This generator will then be a bit of a compiler that cross-compiles one language into another.
Tests are not such a language. They only claim that a particular aspect of the functionality of the code is valid and does not change. In doing so, they will raise the code so that it does not break, even if it is reorganized.
But how would you compare these two paths of development?
1) If the generator works correctly, the specification is always transmitted to the correct code. I claim that this code is tested by design and does not need additional testing. Better TDD generator than generated code.
2) Do you have a specification that leads to the generated code or specifications expressed in tests that ensure that the code works in my eyes.
3) You can combine both ways of development. Create a program structure with a proven generator from the specification, and then enrich the generated code with TDD. Attention: then you have two different development cycles in one project. This means that you must ensure that you can always restore the generated code when the specification changes, and that your additional code still fits correctly in the generated code.
Just one small example: Imagine a tool that can generate code from a UML class diagram. This can be done so that you can develop methods using TDD, but the class structure is defined in UML and you wonβt need to test it again.
source share