8. • Assumes a clean environment (empty
database, redis, solr, etc.)
• Cleans up after itself
• Runs quickly
• Readable, simple to understand
• Tests only one thing at a time
9. • Isolates the class you are testing
• Stubs external dependencies (eg.: vcr)
• Thorough: covers happy and edge cases
• Repeatable: always provides same results
• Doesn’t make unnecessary assertions
• Clearly and consistently named
12. • SOLID code is HIGHLY testable
• TDD forces you to think about your
design
• Bad code is hard to test
• It is a design process, not a testing process
13. “TDD is a robust way of designing
software components (“units”)
interactively so that their behaviour is
specified through unit tests.”
http://blog.stevensanderson.com/2009/08/24/writing-great-unit-tests-best-and-worst-practises/
15. TDD Mantra:
Red => Green => Refactor
http://www.agileapps.co.uk/methodology/continuous.html
16. Mocks and Stubs:
• Mocks set up expectations on messages that
are passed between objects
• Stubs provide canned answers to calls made
during the test
• Only mocks specify expected behavior and
make assertions
• Also know as test doubles (eg.: in RSpec)
Reference: http://martinfowler.com/articles/mocksArentStubs.html