A mock object is a test double that checks whether the system under test makes expected calls to a collaborator. Unlike a fake, which supplies simplified behavior, a mock verifies interactions. section 4.2.3 section 4.3.2
With EasyMock, record expected calls and their responses, then switch the mock to replay mode and pass it to the code under test. Unexpected interactions fail the test; long, complex interaction expectations can make tests brittle. section 4.3.3 section 4.2.3
Pricing service
An OrderProcessor test can replace a difficult PricingService collaborator with a mock and expect getDiscountPercentage(customer, product) to return a chosen discount. section 4.3.3
See the OrderProcessor test using a dynamic mock. section 4.3.3
