Reputation: 1457
What the difference between terms 'Isolation Framework' and 'Mocking Framework'?
Upvotes: 11
Views: 3009
Reputation: 53502
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
The four types are from Lasse Koskela, book Effective Unit Testing. Martin Fowler and Gerard Meszaros list five types:
but the distinction is the same.
Upvotes: 20
Reputation: 8679
Quite often those two terms used interchangeably, but there is an important difference. In my opinion, there is a similar difference as between stubs and mocks. Stub i.e. Isolation Framework only provides predefined outputs, and thus isolates "test" from external system with complex internal state, slow response time, etc. Mock i.e. Mock Frameworks not only provides predefined outputs if needed, but also has pre-programmed with expectations which form a specification of the calls they are expected to receive. Thus mock tracks its usage and fails "test" if used inappropriately. But stub only provides predefined output.
You could found more at Mocks Aren't Stubs article by Martin Fowler
Upvotes: 1