Rule 1: Write the test that forces you to write the code you already know you want to write.
Rule 2: Make it fail. Make it pass. Clean it up.
Rule 3: Don’t go for the gold.
Rule 4: Write the simplest, most specific, most degenerate test that will fail.
Rule 5: Generalize where possible.
Rule 6: When the code feels wrong, fix the design before proceeding.
Rule 7: Exhaust the current simpler case before testing the next more complex case.
Rule 8: If you must implement too much to get the current test to pass, delete that test and write a simpler test that you can more easily pass.
Rule 9: Follow a deliberate and incremental pattern that covers the test space.
Rule 10: Don’t include things in your tests that your tests don’t need.
Rule 11: Don’t use production data in your tests.
Rule 12: Decouple the structure of your tests from the structure of the production code.
Rule 13: As the tests get more specific, the code gets more generic.
Rule 14: If one transformation leads you to a suboptimal solution, try a different transformation.
Rule 15: Avoid using debuggers.
reference
- 《Clean Craftsmanship: Disciplines, Standards, and Ethics》