views:

965

answers:

12

I am looking for a book or online resource that gives a good overview of the subject, and is also practical for implementing unit testing. The book should be useful for users of different programming languages.

+18  A: 

I read Kent Beck's Test Driven Development : By Example and I think it's fine. Also, Kent is one of the main advocates of unit testing.

Roman Plášil
+1 on this, helped me a LOT.
Rob Cooper
It's a light introduction. xUnit Test Patterns has far more detail.
Don Kirkby
And it is short and easy to read. Highly recommended.
Brian Rasmussen
+5  A: 

Pragmatic Unit Testing With NUnit. Most of the information in the book is generic, and if you happen to be using NUnit, then so much the better. I believe there's a version of the book JUnit, as well.

Mark Bessey
+1  A: 

It's not a "book", but I am blogging (hopefully clear enough for "newbies" but concise enough to make it useful) on my "TDD and Unit Testing" adventures on my blog.

It's still a read, and I only have my "Getting Started" article up at the moment, but I am getting great feedback and have lots more planned.

If you have a read, feedback is always welcome, I am really trying to improve my blog content and as with most things, comments from people such as yourself make the difference.

Still a read, and I often print out blog posts to read before bed :)

Rob Cooper
+7  A: 

http://xunitpatterns.com/ will probably become the standard reference.

Great book that everyone should read +1 vote. I thought I knew what unit-testing was before but I didn't
Mendelt
+1  A: 

I second the Kent Beck book choice : "Test Driven Development by example". Easy to read, and providing a good sets of prtactices.

philippe
+6  A: 

Test Driven Development: By Example

Having taught myself TDD through podcasts, blogs and so forth I bought this book. I really wish I'd bought this book before I started. It's perfect for someone new to the world of TDD, and gives you some great sound bytes for helping convince managers and so forth that it is a good idea.

Garry Shutler
A: 

I've read both the Kent Beck book and Pragmatic Unit Testing and recommend them both - depending on what you're looking for.

The Kent Beck book is about TDD - and is one of the best books on the subject. Pragmatic Unit Testing is about writing unit tests (not via TDD)

Alan
A: 

I'd recommend Kent Beck's book first. I also found Test Driven Development in Microsoft.NET to be pretty good if you are a Microsoft shop.

Erikk Ross
+4  A: 

Kent Beck's Test Driven Development: By Example is short, readable and language agnostic (examples are given in one of Java, Python or Smalltalk). He explains the basic xUnit test framework pattern by building an xUnit implementation from scratch — using TDD every step of the way. Although it is really a book about TDD rather than just unit testing, it does a good job of demonstrating how to test your code unit by unit, without assuming any prior knowledge of automated testing.

Some other answers mention Gerard Meszaros' xUnit Test Patterns: Refactoring Test Code book (and website). It's a good book that covers a lot of concepts that Kent Beck's TDD book doesn't, and it starts with a nice walkthrough of refactoring some typical test code into beautiful unit tests. But it is large (nearly 900 pages, the majority devoted to being a reference for xUnit refactoring patterns), and most of it is quite dry, and frequently repetitious. That introductory walkthrough is very good, but the sheer bulk of the book is likely to scare off someone just looking to “get started”.

So I recommend Kent Beck's book for getting started with unit testing.

spiv
A: 

I liked the book "Unit Test Frameworks". It gives an overview of the various frameworks and insight into their internal workings. Along the way there a good tips on good test driven development practices.

unclerojelio
+3  A: 

As a beginner in unit testing, I really really liked Art Of Unit Testing

I did some researches on books available and this one seemed better than the others to explain what is a good unit test, what should be tested, how to tests existing code, etc.

After looking at the first chapter free online we buyed the early access edition PDF and it was worth every penny.

total
+2  A: 

For starters, if you have a legacy product, none is better than Working Effectively with Legacy Code by Michael Feathers.

Michael Hedgpeth