Useful TDD Concepts and Rules Of Thumb
Test Isolation and Global State
Different tests shouldn’t affect one another. This means we need to reset any per‐
manent state at the end of each test. Django’s test runner helps us do this by creating
a test database, which it wipes clean in between each test. (See also
Chapter 19.)
Working State to Working State (aka The Testing Goat vs. Refactoring Cat)
Our natural urge is often to dive in and fix everything at once … but if we’re not
careful, we’ll end up like Refactoring Cat, in a situation with loads of changes to our
code and nothing working. The Testing Goat encourages us to take one step at a
time, and go from working state to working state.
YAGNI
You ain’t gonna need it! Avoid the temptation to write code that you think
might
be
useful, just because it suggests itself at the time. Chances are, you won’t use it, or
you won’t have anticipated your future requirements correctly. See
Chapter 18for
one methodology that helps us avoid this trap.
112
|
Chapter 6: Getting to the Minimum Viable Site