15 Test Driven Development

Testing and coding can be separate, or the boundary can get really blurry.

TDD:
Writing tests first, before code
Writing only code that makes the test pass
Writing only tests that test the code
A short turnaround cycle
Refactoring early and often: 
Refactoring is the process of changing code without changing
its external functionality. 

Test First Development
Red Green Refactor
Red: write a test (expected to fail) for something the system should do.
Green: write code to make this test work, while not losing any other tests
Refactor (as needed)

What should we do next? (Repeat)
1 Write a test for functionality which has not been written yet.
2 Run test suite—only the newly written test should fail. 
  If not, first figure out why other tests are failing and fix that problem.
3 Write enough code to make that test pass, without causing other tests to fail.
4 Run test suite—if any test fails, go back to step 3. 
  If all tests pass, continue.
5 Refactor code that you have written, and/or any associated code.
6 Run test suite—if any tests fail, go back to step 5. 
  If all tests pass, continue.
7 If there is any more functionality to add, go to step 1. 
  If there is no more functionality to add,the application is complete!

Principles:
YAGNI (You Ain’t Gonna Need It)
KISS (Keep It Simple, Stupid)
Fake It ’Til You Make It
Avoid Slow Running Tests
Remember That These Are Principles, Not Laws

Development automatically creates tests
No ambiguity if everyone agrees on what results of the test should be
small steps
code very testable

drawbacks:
must write many tests
less up front time for architecture decisions
risk of making changes late in process