Good question. A couple of giants have thought about this. For them TDD (recommended by others in this thread) is not the way. Leslie Lamport:
Etc, see Untimely meditations about software engineering for the full text.
Donald Knuth wrote about “Literate programming”:
Knuth only rarely uses unit tests:
Here explicit about extreme programming (TDD etc):
Others / related:
1 Like