Chapter 2. Beginning TDD
Listing 2.1. Creating a skeleton for our tests
Listing 2.2. Adding a test method
Listing 2.3. Writing the actual test
Listing 2.4. Satisfying the compiler by adding empty methods and constructors
Listing 2.5. Stubbing out methods of the Template class to make compilation succeed
Listing 2.6. Passing as quickly as possible with a hard-coded return statement
Listing 2.7. Forcing out the hard-coded return statement with another test
Listing 2.8. Making the second test pass by storing and returning the set value
Listing 2.9. Applying triangulation for the static template text
Listing 2.10. Our first attempt at handling the variable for real
Listing 2.11. Search-and-replace for handling multiple variables
Listing 2.12. Our test code up to this point—can you spot anything to refactor?
Listing 2.13. Test code after removing a redundant test and unifying the fixture
Listing 2.14. Testing for an exception
Listing 2.15. Checking for remaining variables after the search-and-replace
Listing 2.16. Extracting the check for missing variables into a method
Listing 2.17. Extracting another method from evaluate()
Listing 2.18. Testing for an expected exception
Listing 2.19. Writing a simple performance check to act as an early warning system
Chapter 3. Refactoring in small steps
Listing 3.1. Making sure we can locate all matches within a given String
Listing 3.2. Parsing an empty template using the TemplateParse class