Write the Test First, and then write only the code needed to make the test pass. This keeps the software you build focused and testable. Tests should support you in refactoring safely and test code should be kept as CLEAN as production code.
In this chapter, we discovered…
The why behind test-first development, not just the how.
Test-first development can easily be done wrong if you write too many tests or write implementation-dependent tests that can impede refactoring code.
Our tests should support refactoring code, and to do this write only the tests needed to specify the behavior you’re creating.
Doing test-first development helps quality assurance, but it doesn’t replace QA.
Test-first development involves building features by writing a failing test, then writing just enough code to make that failing test pass. Then refactor as needed and repeat by writing another failing test.
When done correctly, test-first development helps developers create testable code that’s more maintainable, but TDD can become more of a burden than an asset when done poorly.
Gamma, Erich. “Test Infected.” http://junit.sourceforge.net/doc/testinfected/testing.htm