Effective Unit Testing: A guide for Java developers

Category: Programming
Author: Lasse Koskela
4.2
This Month Stack Overflow 1

Comments

by anonymous   2019-01-13

I feel the accepted answer is wrong, mock frameworks are isolation frameworks as well.

Section 5.1 from Roy Oshroves book "The Art of Unit Testing" says

An isolation framework is a set of programmable APIs that make creating mock and stub objects much easier. Isolation frameworks save the developer from the need to write repetitive code to test or simulate object interactions.

This definition may sound a bit bland, but it needs to be generic in order to include the various isolation frameworks out there. Isolation frameworks exist for most languages that have a unit-testing framework associated with them. For example, C++ has mockpp and other frameworks, and Java has jMock and EasyMock, among others. .NET has NMock, Moq, Typemock Isolator, and Rhino Mocks.

In a blog post by him he mentions that

isolation framework (mocking framework… but that is a horrible name for it. the word mock is overloaded already)

So they typically refer to the same thing. An isolation framework can be used to initiate mocks, but it also applies to other test doubles. An isolation framework would be a superset of which a mock framework is a part of.

A test double is an umbrella term for

  • test stubs
  • fake objects
  • test spies and
  • mock objects

The four types are from Lasse Koskela, book Effective Unit Testing. Martin Fowler and Gerard Meszaros list five types:

  • dummy objects
  • fake objects
  • stubs
  • spies and
  • mocks

but the distinction is the same.