Tutorial by Examples

A stub is a light weight test double that provides canned responses when methods are called. Where a class under test relies on an interface or base class an alternative 'stub' class can be implemented for testing which conforms to the interface. So, assuming the following interface, public inter...
The terms Mock and Stub can often become confused. Part of the reason for this is that many mocking frameworks also provide support for creating Stubs without the verification step associated with Mocking. Rather than writing a new class to implement a stub as in the "Using a stub to supply c...
Mocks are used when it is necessary to verify the interactions between the system under test and test doubles. Care needs to be taken to avoid creating overly brittle tests, but mocking can be particularly useful when the method to test is simply orchestrating other calls. This test verifies that ...

Page 1 of 1