JaVa
   

Summary

A dummy object is an object that replaces another object for the duration of a test. It implements the same interface as the "real" object, but replaces complex calculations with constant returns, throws exceptions when ordered to do so, and does some additional parameter validation or other things needed only in the test. Mock objects are special dummy objects that additionally handle the specification of the expected behavior and the validation of the actual behavior. The main argument in favor of using dummies is independence in the tests and related design improvements. There are many more benefits and drawbacks such that mock objects should not be used reflexively but solely by carefully weighing the positive and negative implications against each other. Typical apps include access to files or other external resources and integration of external components. Dummy objects and mocks will also play an important role later on in , Persistent Objects, and , Web apps.


JaVa
   
Comments