Mock or “fake out” external dependencies (e.g. databases) Run fast Integration tests: Test the whole system working together Can run slow Can be brittle
haven’t written the implementation code yet, the tests should fail. 2. Write just enough code to get the test to pass. 3. Move on or refactor “Red – Green – Refactor”
Someday someone other than you will have to understand your code Someday you will wonder what your code was supposed to do Living, breathing documentation!
time to constantly manually test code to see if it’s all working It takes time to figure out what code is supposed to do It takes time to figure out if my changes will break something in the code It takes time to rewrite code Think long-term, not short-term!!
development: results and experiences of four industrial teams” http://research.microsoft.com/en-us/projects/esm/nagappan_tdd.pdf Cost of Testing, by Misko Hevery (Agile Coach/Java developer at Google) http://misko.hevery.com/2009/10/01/cost-of-testing/ TDD Derangement Syndrome, by Uncle Bob Martin http://blog.objectmentor.com/articles/2009/10/07/tdd-derangement- syndrome
You Introduce TDD into an Organization or Team?, by Jeremy Miller http://codebetter.com/blogs/jeremy.miller/archive/2006/06/27/146899.aspx How to get started with TDD, by Misko Hevery (Java examples) http://misko.hevery.com/2009/11/17/how-to-get-started-with-tdd/ TDD Starter Kit – Sample Projects and Links (C# examples) http://jonkruger.com/blog/2009/07/23/tdd-starter-kit-sample-projects-and-links/ Pair Programming Bot http://pairprogrammingbot.com/
Test Driven Development: By Example by Kent Beck Test Driven Development: A Practical Guide by David Astels The RSpec Book: Behaviour Driven Development with RSpec, Cucumber, and Friends by David Chelimsky, Dave Astels, et. al.
http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata Prime Factors kata http://www.butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata Greed game (part of the Ruby koans) http://github.com/edgecase/ruby_koans Katacasts (watch screencasts of people doing various katas) http://www.katacasts.com/