DEV Community

Discussion on: The mindset behind Test Driven Development (TDD)

Collapse
 
vdedodev profile image
Vincent Dedo

Writing tests after writing the code is hard. As the code can be written without testability in mind, it might not be testable, or properly decoupled/modularized.

When we write tests after the code, it leaves holes in the test suite, as we are highly likely to miss some corner cases here and there.

Writing tests after code does not often lead to this as long as keep in mind the fact that the first user of your code is the test suite. Dependency injection and SRP make testing quite easy.