Posts

Showing posts from September, 2014

Test Driven Development with Alfresco - Part 3 Test Doubles

So far in this series I have given an overview of Test Driven Development and briefly described Inversion of Control.  Proper unit testing requires testing a unit in isolation of its dependencies.  The only thing you care about in relation to a unit's dependencies is how the unit interacts with those dependencies not so much what those dependencies do.  Inversion of Control (IoC) allows us to separate the creation of dependencies from the unit itself but we still need to inject something into our units that we can use for each dependencies.  This is where test doubles come in.  A test double takes the place of an actual dependency. Types of Test Doubles There are a lot of different opinions on what test doubles are but the most commonly accepted standard would be from Gerard Meszaros book xUnit Test Patterns: Refactoring Test Code (Addison-Wesley).  These are: Dummy Doesn't do anything and returns null, zero, or the return types nearest equivalent.  Essentially a dummy d