Specify Behaviors with Tests to create living specifications. We walked through an example of building some basic functionality test-first and saw how to use tests to specify behavior. When developers see the benefit of doing test-first development, they can become test infected and want to do all their development test-first.
In this chapter, we discovered…
How to use your test suite to not only verify behavior but also to specify it.
By instrumenting tests, you can clearly state their purpose and they become a form of living specifications.
Tests provide a “safety net,” allowing you to refactor code and instantly know if you’ve made a mistake.
By writing tests to specify behaviors, you’ll always know the right kind and number of tests to write to build out any behavior.
When done correctly, test-driven development helps developers create testable code that’s more maintainable, but TDD can fail when done poorly. By seeing tests as executable specifications for code, you’ll know exactly what tests to write for any given behavior. We walked through an example of doing test-first development so you can grasp the basic concept even if you’re not a programmer.