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.
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
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...
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.
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.
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.
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.