What book would you recommend to learn test driven development? Preferrably language agnostic.
7 Answers

- 114,442
- 31
- 189
- 228
-
1These seem old. I know the subject matter doesn't really age, but I expected more recent options, a priori. Am I worried over nothing? – cape1232 Jul 23 '10 at 01:25
-
I was wondering the same thing. API and frameworks are evolving. With complexity growing at higher level of abstractions, it seems harder to apply the principles in Kent Beck TDD book at least. – B2F Oct 03 '14 at 08:28
Growing Object-Oriented Software, Guided by Tests by Addison-Wesley - it is about mocking frameworks - JMock and Hamcrest in particular.
From description of the book:
Steve Freeman and Nat Pryce describe the processes they use, the design principles they strive to achieve, and some of the tools that help them get the job done. Through an extended worked example, you’ll learn how TDD works at multiple levels, using tests to drive the features and the object-oriented structure of the code, and using Mock Objects to discover and then describe relationships between objects. Along the way, the book systematically addresses challenges that development teams encounter with TDD--from integrating TDD into your processes to testing your most difficult features.
EDIT: I'm now reading Working Effectively with Legacy Code by Michael Feathers which is pretty good. From the description of the book:
- Understanding the mechanics of software change: adding features,
fixing bugs, improving design, optimizing performance- Getting legacy code into a test harness
- Writing tests that protect you against introducing new problems
- This book also includes a catalog of twenty-four dependency-breaking techniques that help you work with program elements in isolation and make safer changes.
I read it already, it is one of the best programming books I've ever read (I personally think that it must be called Refactoring to Testability - it describes the processes for making your code testable). Because a testable code is good code.

- 11,167
- 5
- 49
- 74
-
1Just one point. GOOS is not really about mocking. It started that way and turned into something bigger. – Steve Freeman Oct 20 '14 at 11:10
-
GOOS is a great book. However, I wouldn't describe it as "it is about mocking frameworks". – Rudolf Adamkovič May 27 '17 at 21:19
For me, this is the best one:
- Test Driven Development: By Example by Kent Beck

- 2,673
- 3
- 22
- 23
-
5This book is really not interesting. I can't understand why people recommend it. – Michal Czardybon Aug 27 '12 at 19:59
-
It's subtle. At first reading it doesn't look like much. Then you go back and reread after having been practicing for a couple of years and there's lots of interesting ideas. – Steve Freeman Oct 20 '14 at 11:09
-
Fairly recent reasonably written book The Art of Unit Testing. I am surprised it wasn't mentioned here.

- 5,132
- 8
- 41
- 51
The Astels book is a solid introduction, Beck's book is good on the underlying concepts, Lasse Koskela has a newish one (Test Driven: TDD and Acceptance TDD for Java Developers). Osherove's book, as he says, is about Unit Testing, rather than TDD. I'm not sure that the Pragmatics' TDD book has aged as well as their original book.
Most everything is Java or C#, but you should be able to figure it out yourself.

- 37,241
- 25
- 195
- 267

- 2,707
- 19
- 14
-
1Lasse Koskela wrote "Practical TDD and Acceptance TDD for Java Developers", which was published in October 2007 - is that newish? – dnord Jul 18 '10 at 14:41
-
And ours is out now :) http://www.growing-object-oriented-tests.com – Steve Freeman Jul 23 '10 at 00:35
-
riddle references :) Coud not find the exact "Pragmatics' TDD" apart the book for embbedded dev in c : http://www.amazon.com/Driven-Development-Embedded-Pragmatic-Programmers/dp/193435662X – Matthieu Nov 01 '11 at 15:28
-
It would have to be http://pragprog.com/book/utc2/pragmatic-unit-testing-in-c-with-nunit or http://pragprog.com/book/utj/pragmatic-unit-testing-in-java-with-junit since the embedded book was only out in 2011 – prusswan Mar 14 '14 at 07:21
I'm a big fan of almost anything from the Pragmatic Bookshelf, but these two really helped drive the point home for me:
The Pragmatic Programmer: From Journeyman to Master. This ages really well. I'd recommend it to any developer.
Pragmatic Unit Testing in C# with NUnit, 2nd Edition. Don't let the title scare you. The concepts are pretty language agnostic, even with the C# examples.

- 15,076
- 6
- 55
- 70