title: How to use scala mock to provide an alternative implementation of a class as stub for test?
body: <p>I found in a project i'm about to contribute with some external lib, that for testing purpose they set up a mock database manager. However what this database manager does, is creating an in-memory database and working with it. This is for testing purpose. </p>
  
  <p>The framework used is Jmockit. </p>
  
  <p>I try to find out how i could reproduce that in scalamock, but could not figure out. </p>
  
  <p>Here how this is set up in jmockit: </p>
  
  <pre><code>/**
   * Mocks a DatabaseManager so unit tests can be run without a real DB connection
   * The code is basically the same as the original DatabaseManager but it
   * establishes a connection to an in-memory database.
   *
   * @author pvillega
   */
  @MockClass(realClass = DatabaseManager.class)
  public class MockDatabaseManager {...}
  </code></pre>
  
  <p>Is there anything that could support that in scalamock.  I know this is related to how the all application has been developed. Especially how they used or did not used dependency injection. But nevertheless we have to deal with legacy code sometime :)  (most of the time)</p>
  
  <p>The only thing i see is writing all the function of a stub. 
  A - However that is just not nice. 
  B - Also it is not a full class that can retain state. So everything would have to be manage in the enclosing class that is creating the stub. 
  c - Again, legacy code do a lot of funny things inside the class, so i would have to recreate all the code and etc...
  d - I would appreciate to reuse what they MockDatabaseManager. </p>
  
  <p>Any advise?  </p>