Automated Unit Testing

by Caleb Jenkins

As a consultant, development mentor, and agile coach, I've worked with many dozens of organizations and hundreds of developers who have struggled through the realities of implementing automated unit tests. Most developers have at least heard of unit tests. They even believe that implementing automated tests would be a good idea and would make their code better, even if they're not sure exactly how or why — or rather, they're not fully convinced that the added time and complexity of writing tests can make their code better.

If you are a developer, you already know how to write code — you probably get paid for it — and won't tests just slow you down? Won't they give you more code to write and maintain? If you've ever struggled with these notions about writing tests, know that you're not alone! If you have these concerns now, you will probably be a better test writer in the long run.

This chapter lays the right foundation for your tests, and gives you the practical skills and tools to make unit testing a natural part of your coding activity.


At their core, unit tests are just code you write to test code that you wrote — or, better yet, code that you are going to write. With automated unit tests, you can run and rerun hundreds, or even thousands, of tests with the click of a single button, or have the test run automatically on the server whenever a developer checks in new code to source control.

Scope, LEGOs, and Connected ...

Get Real World .NET 4, C#, and Silverlight®: Indispensible Experiences from 15 MVPs now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.