title: What's the difference between faking, mocking, and stubbing?
body: <p>I know how I use these terms, but I'm wondering if there are accepted definitions for <strong>faking</strong>, <strong>mocking</strong>, and <strong>stubbing</strong> for unit tests?  How do you define these for your tests?  Describe situations where you might use each.</p>
  
  <p>Here is how I use them:</p>
  
  <p><strong>Fake</strong>: a class that implements an interface but contains fixed data and no logic.  Simply returns "good" or "bad" data depending on the implementation.</p>
  
  <p><strong>Mock</strong>: a class that implements an interface and allows the ability to dynamically set the values to return/exceptions to throw from particular methods and provides the ability to check if particular methods have been called/not called.</p>
  
  <p><strong>Stub</strong>: Like a mock class, except that it doesn't provide the ability to verify that methods have been called/not called.</p>
  
  <p>Mocks and stubs can be hand generated or generated by a mocking framework.  Fake classes are generated by hand.  I use mocks primarily to verify interactions between my class and dependent classes.  I use stubs once I have verified the interactions and am testing alternate paths through my code.  I use fake classes primarily to abstract out data dependencies or when mocks/stubs are too tedious to set up each time.</p>