Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

If I want to learn TDD on my own, where would I start apart from the usual Google Search?

Are there any books that you would recommend or any method that you followed to learn it on your own?

I am a C# Developer if in case that made a difference.

share|improve this question

closed as off-topic by gnat, MichaelT, GlenH7, Yusubov, Dan Pichelman Aug 26 '13 at 17:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – gnat, MichaelT, GlenH7, Yusubov, Dan Pichelman
If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

5 Answers 5

up vote 8 down vote accepted

It uses Java and Python, but a good book to learn TDD from is Test Driven Development: By Example.

Quite simply, test-driven development is meant to eliminate fear in application development. While some fear is healthy (often viewed as a conscience that tells programmers to "be careful!"), the author believes that byproducts of fear include tentative, grumpy, and uncommunicative programmers who are unable to absorb constructive criticism. When programming teams buy into TDD, they immediately see positive results. They eliminate the fear involved in their jobs, and are better equipped to tackle the difficult challenges that face them. TDD eliminates tentative traits, it teaches programmers to communicate, and it encourages team members to seek out criticism However, even the author admits that grumpiness must be worked out individually! In short, the premise behind TDD is that code should be continually tested and refactored. Kent Beck teaches programmers by example, so they can painlessly and dramatically increase the quality of their work...

share|improve this answer
1  
+1 this is THE book for learning TDD. Wish I could +10. Kent has also recently done a screencast demonstrating TDD for Pragmatic Programmers that I highly recommend. It's one thing to read it, it's another entirely to watch a master do it step by step. –  Rein Henrichs Apr 13 '11 at 18:31
add comment

Have a look at The Art Of Unit Testing. It has a lot of examples in .NET, but using Rhino Mocks rather than Moq, which I prefer.

It covers TDD and Unit-Testing in general very well.

Microsoft also has a book: Test Driven Development in .NET (Microsoft Professional), but I have yet to read it.

share|improve this answer
1  
I have only read the Test Driven Development in .NET. I thought it was cool that it implements a full application with different layers rather than just demonstrating separate examples. –  simoraman Apr 14 '11 at 7:00
3  
I like "the Art of Unit Testing" too - but that book has nothing to do with TDD - as per author's own words. The book is an excelent source for unit testing - kind of prerequiste for TDD - but it is not the source to learn about TDD per se. –  ratkok Jun 30 '11 at 4:37
add comment

All of the previous answers are great starting points, but to be honest you should start trying to do TDD. To start with accept that any tests are better than no tests and slowly you should start see patterns in your own development. Things that work really well, things that are harder to test and resistant to change. When you encounter the later take a step back and see what is different / impedes the change. Slowly you should feel things changing. For me, the "hump point" was realising that when I did TDD properly I could got to lunch or even go home for the weekend and when I got back, know exactly where I was at. The measureable metric was that I felt so much more relaxed. To answer some of the critics of TDD, it does take a measure-able more amount of time up front, but if you expect your system to last then you should see pay back in the long term.

share|improve this answer
add comment

Since you're asking about c#, Pragmatic Unit Testing in C# with NUnit Might be a good choice. I have not read the others though so I cannot compare.

One thing I dislike is that it uses NUnit Mocks. I much prefer Moq personally. That's a nitpick though, it's not about the language or framework, it's about the practice and process.

share|improve this answer
add comment

Find a coding dojo which uses TDD as part of the exercise. Alternately, start one :) or you can start trying out the katas with TDD yourself.

Else, find somebody who has been using TDD a lot and ask him what his/her workflow is. I have found having someone talk and discuss ideas with you is very important when you are trying out a new process.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.