tags:

views:

557

answers:

4

Short backstory: I am a self-taught developer. This can lend to all manner of bad habits and misconceptions, but I am constantly learning and want to improve my skills. Insofar as I want to be a developer, I want to be a good developer. With that in mind...

Unit testing is a mystery to me. I don't know what it is, how to do it, and so on. I would just google for this stuff, but I think this could be a good resource to have on SO. So, what is a good, comprehensive, detailed introduction to unit testing?

Edit: In case it matters, I mostly write Javascript and PHP.

+5  A: 

This may be of interest.

“The Art of Unit Testing“. by Roy Osherove

The book concentrates on unit testing for the .Net developer. And it covers these subjects (as taken from the manning website).

  • Introduction to unit testing and the basics of writing real-world unit tests with NUnit
  • Best practices for writing maintainable, trustworthy, readable tests
  • Mock Objects and integration testing in-depth
  • Reference chapters for NUnit, Rhino.Mocks, and TypeMock.NET
  • Database unit testing
  • Testing legacy code
  • Designing for testability

From: http://blogs.lessthandot.com/index.php/Architect/IntroductionArchitectureDesign/an-interview-with-roy-osherove-autor-of-

Remou
+3  A: 

Test-Driven Development by Example by Kent Beck, one of the developers of JUnit, has everything you need to know about unit testing. The first section of the book goes through several examples using Java and JUnit, showing you how to properly unit test a project. The second part uses Python to show you how to build a unit testing framework. It's worth a look.

Bill the Lizard
+5  A: 
jop
I had actually never heard of this one. I have the Pragmatic Programmer and love it. I also have just about every other book on software testing, so I guess I need this one to complete my collection. :)
Bill the Lizard
Me either. I think I may have to get the credit card out.
BlackWasp
I really like this book as an introduction to Unit Testing.
Mark Bessey
+1  A: 

You might want to give a look at the bowling game episode. The article is not very long, and can be read quite quickly. However the language used is Java, but the code is simple.

The discussion illustrates not only unit testing, but also pair-programming and emergent design.

Shorter than a book, this format gives you a good grasp on writing unit tests with Test-Driven-Development (TDD).

philippe