mocking for testing happen if the data provided by systems that test depends on do not supply repeatable data this can happen for several different reason but common cause is because they return real data such real data may be subject to changefor example consider system that uses data feed for the current exchange rate between funds and dollars if the associated test confirms that trade when priced in dollars is correctly converted to funds using the current exchange rate then that test is likely to generate different result every time it is run in this situation it would lie better to mock out the current exchange rate service so that fixed/known exchange rate is used the real system is not reliable enough in some cases the real system may not be reliable enough itself to allow for repeatable tests the real system may not allow tests to be repeated finallythe real system may not allow tests to be easily repeated for examplea test which involves lodging trade for certain number of ibm shares with an trade order management system may not allow that tradewith those sharesfor that customer to be run several times (as it would then appear to be multiple tradeshoweverfor the purposes of testing we may want to test submitting such trade in multipel different scenariosmultiple times it may therefore be necessary to mock out the real order management system so that such tests can be written what is mockingthe previous section gave several reasons to use mocksthe next thing to consider then is what is mockmocksincluding mock functionsmethods and mock objects are things thatpossess the same interface as the real thingwhether they are mock functionsmethods or whole objects they thus take the same range and types of parameters and return similar information using similar types define behaviour that in some way represents/mimics real exemplar behaviour but typically in very controlled ways this behaviour may be hard coedmay really on set of rules or simplified behaviourmay be very simplistic or quiet sophisticated in its own right they thus emulate the real system and from outside of the mock may actually appear to be the real system in many cases the term mock is used to cover range of different ways in which the real thing can be emulatedeach type of mock has its own characteristics it is therefore useful to distinguish the different types of mocks as this can help determine the style of mock to be adopted in particular test situation