What is Unit Testing not?


An ex-colleague of mine was telling me about a situation that he experienced on a project recently whereby his team had written a comprehensive unit test suite for a component designed to generate XML files for consumption in another system. Their code passed all the unit tests, yet when they delivered the component to the … Continue reading What is Unit Testing not?

Advertisements

Unit Testing – testing class contracts


It’s been a while since I last posted, and I thought I’d write something that often gets overlooked when unit testing – what the boundary is for a given set of unit tests. When you write unit tests on e.g. a public method on a class, something that you need to keep in mind is … Continue reading Unit Testing – testing class contracts

Using Unity Call Handlers to compose logic


The most common use of Unity Call Handlers (or Interceptors) is for cross-cutting concerns. I’ve demonstrated the use of such handlers in the past for things such as logging or caching. However, there’s another use for these handlers that allows us to build reusable blocks of business-related code that can be composed together to act … Continue reading Using Unity Call Handlers to compose logic

Why I Hate the Template Pattern – Part 2


In my last post, I discussed in detail why exactly I don’t recommend the use of the Template for writing testable code. Here I want to illustrate an alternative to it, but before I do that, I want to talk about a more fundamental aspect of OO design. Inheritance vs Composition The way I see … Continue reading Why I Hate the Template Pattern – Part 2

Why I Hate the Template Pattern – Part 1


We’ve all been there and done it – written some code that at the time seemed great but you look back on it and think “why!”. I’m hoping to save you from at least one of those situations today with a brutal dissection of the Template pattern. Seductively, it offers you a quick and easy … Continue reading Why I Hate the Template Pattern – Part 1