A mock is a stub on steroids. It is a stub and much more. Like a stub, a mock object also returns values that are premeditated. Apart from this, a mock object can also be programmed with expectations about the number of times the mock is called and in what order it is invoked. The use of mock objects leads to tests that test specific details about the interaction between the classes without the use of the actual class.
Expectations are set on mock objects to define their behavior. Expectations are also a way of asserting that the class under test is working as expected. Exceptions can set expected responses, sequences in which methods should be called, or any errors that were expected. In general, the expectations just set the behavior of the mock object. It does not result in a test failure if one or more expectations are not invoked.
Example: If I have set my mock object with the expectation that it will be called three times and if my test only calls it one time...