Help


from Wikipedia
« »  
The use of mock objects can closely couple the unit tests to the actual implementation of the code that is being tested.
For example, many mock object frameworks allow the developer to check the order of and number of times that mock object methods were invoked by the real object being tested ; subsequent refactoring of the code that is being tested could therefore cause the test to fail even though all mocked object methods still obey the contract of the previous implementation.
This illustrates that unit tests should test a method's external behavior rather than its internal implementation.
Over-use of mock objects as part of a suite of unit tests can result in a dramatic increase in the amount of maintenance that needs to be performed on the tests themselves during system evolution as refactoring takes place.
The improper maintenance of such tests during evolution could allow bugs to be missed that would otherwise be caught by unit tests that use instances of real classes.
Conversely, simply mocking one method might require far less configuration than setting up an entire real class and therefore reduce maintenance needs.

2.057 seconds.