title: Mocking a class vs. mocking its interface
body: <p>For a unit test, I need to mock several dependencies. One of the dependencies is a class which implements an interface:</p>
  
  <pre><code>public class DataAccessImpl implements DataAccess {
      ...
  }
  </code></pre>
  
  <p>I need to set up a mock object of this class which returns some specified values when provided with some specified parameters.</p>
  
  <p>Now, what I'm not sure of, is if it's better to mock the interface or the class, i.e.</p>
  
  <pre><code>DataAccess client = mock(DataAccess.class);
  </code></pre>
  
  <p>vs. </p>
  
  <pre><code>DataAccess client = mock(DataAccessImpl.class);
  </code></pre>
  
  <p>Does it make any difference in regard to testing? What would be the preferred approach?</p>