Practical .NET Unit Testing – Free paper released

I’ve been working on a unit testing paper that sums up my experience in unit testing, and discusses some of the core information that I feel is important about the subject. It’s very much a work in progress, but I wanted to get it out sooner rather than later. I’ll be continuously updating it as time goes on.

Update: I updated the PDF location to one that doesn’t require registration.

Practical .NET Unit Testing

There are some really great books out there about unit testing, but I think some of them are trying too hard to be long enough to be considered a “book”. I set out to create a document that fills the gap between the various snippets of information from blog posts, and the comprehensive books on the subject. If you’re interested in something a bit more in-depth, here are some great books on the subject:

The paper currently consists of 5 main sections:

  • Why Write Unit Tests?
  • Unit Test Mechanics
  • Common Unit Testing Strategies
  • Designing for Testability
  • Advanced Techniques

Here is a more complete snapshot of the current outline:

  • Introduction
  • Unit Testing & Managers
  • What Unit Tests Really Do
  • Types of Testing
  • Testing Framework
  • Test Runner
  • Unit Test Structure
  • Other Test Attributes
  • What is Refactoring?
  • Test Driven Development
  • Evolving Code
  • When Should You Write Unit Tests?
  • Test is for Functionality, Not Code!
  • The Constraints of Reality
  • Interfaces – Quick Overview
  • Using a Mocking Framework
  • Stubs
  • The Test Driven Design Paradox
  • Testing Under Pressure
  • Extracting Duplicate Logic
  • Modular Design Benefits

So what are you waiting for? Go check it out online instantly, you can even download it as a PDF if you like. Is anything missing? Is anything just plain wrong? I’d love to hear your feedback.

Remember, if you want to hear more about unit testing, I’ll be speaking in Northeast Wisconsin Saturday, May 9th.

14 comments on “Practical .NET Unit Testing – Free paper released
  1. I really like your paper. I’m fairly inexperienced with unit testing and it’s really helped to clarify things for me, especially the part about mock objects.

    Cheers

  2. Typemock says:

    A really good paper !

  3. Peli says:

    You should talk about data-oriented unit tests i.e. MbUnit’s RowTest, etc… All unit test frameworks support this kind of testing. Once you’re there, you should take a look at Pex (http://research.microsoft.com/pex) which should give an idea where automated unit testing might be headed.

    Keep on the good work,
    Peli

  4. Samuel Carrijo says:

    On the 19th slide, there’s an example using the CompareTo method of IComparable, requiring it to return 1 for bigger, -1 for smaller; any other value if they are the same.

    Looking at the documentation of the method, I’ve checked that it works like this

    Less than zero (not strictly -1) => smaller
    Zero (strictly zero) => equal
    Greater than zero (not strictly 1) => bigger

    Check the table at http://msdn.microsoft.com/en-us/library/system.icomparable.compareto(VS.71).aspx

    Just a minor contribution. Still reading the paper, and liking what I read so far.

  5. Samuel Carrijo says:

    Another point in slide 19:

    “Programming the class against the interfaces is elegant for number of reasons. First, as I mentioned, we’re defining the “how” for retrieving the email addresses. (…)”.

    IMHO, interfaces define the “what” who implements the interface does, no matter how. The interface implementation defines “how” to do the “what”.

    Also, do any of you guys know any mock framework that lets me create partial mock without the need to create interfaces for everything or declaring a method as virtual? It doesn’t seem right to me modifying good code (e.g. creating an unnecessary interface) just to make testing easier.

    Thanks in advance

  6. PB says:

    [...] – Practical .NET Unit Testing [...]

  7. slamidtfyn says:

    Very good paper. Looking forward to read the yet not finished sections.

  8. B A L U says:

    Good Stuff.

    Thank.

  9. Punit says:

    Appreciate your time and effort. thank you!

  10. Schöner und motivierender Beitrag. Danke

  11. Schöner und motivierender Beitrag. Danke

  12. HHS says:

    Thank you very much!

7 Pings/Trackbacks for "Practical .NET Unit Testing – Free paper released"
  1. [...] nettes Ebook zum Thema Unit Testing unter C# / [...]

  2. [...] Practical .NET Unit Testing – Free paper released I’ve been working on a unit testing paper that sums up my experience in unit testing, and discusses some of the core information that I feel is important Share and Enjoy: [...]

  3. [...] ytechie tech blog habe ich soeben ein interessantes eBook zum Thema Unit Testing gefunden. Es ist (nicht zuletzt aufgrund der bisher nur 25 Seiten) etwas oberflächlich, deckt [...]

  4. [...] Practical .NET Unit Testing – Free paper released (Jason Young) [...]

  5. [...] Practical .NET Unit Testing – Free paper released This paper currently consists of 5 main sections: * Why Write Unit Tests? * Unit Test Mechanics * Common Unit Testing Strategies * Designing for Testability * Advanced Techniques (tags: development .net unittesting) [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>