up previous next contents index
Next: Notes Up: Unit Testing Database Code Previous: Create a test database   Contents   Index


Use mock objects

A second line of thought when testing database code involves the use of ``mock objects'' to simulate the database.

Pro's:

  1. Runs much faster than tests against a real database.
  2. Lets you test database exception conditions.
  3. Can test interesting things like exceptions, and returning connections back to the pool.

Con's:

  1. Any time you deal with mock objects you have to think about the time you are investing to create the artificial support environment.
  2. When the database changes your tests may not fail, because you are not testing against it.


up previous next contents index
Next: Notes Up: Unit Testing Database Code Previous: Create a test database   Contents   Index