Questions and answers
- What are the two key rhythms of TDD?
Arrange, Act, Assert, and RGR. The first rhythm helps us write the body of the test while designing the interface to our production code. The second rhythm works to help us create and then refine the implementation of that production code.
- How can we write tests before code?
Instead of thinking about how we are going to implement some code, we think about how we are going to call that code. We capture those design decisions inside a unit test.
- Should tests be throwaway code?
No. In TDD, unit tests are given equal weight to the production code. They are written with the same care and are stored in the same code repository. The only difference is that the test code itself will not be present in the delivered executable.
- Do we need to refactor after every test pass?
No. Use this time as an opportunity to decide what refactoring is needed. This applies to both the production...