| |
| | Unit testing with mock objects |
 | | For example, to unit test an object that uses a database, it may be burdensome to install, configure, and seed a local copy of the database, run your tests, then tear the local database down again. |
 | | As long as the class being tested behaves as expected, it won't notice the difference, and the unit test can check that the proper query was emitted. |
 | | Finally, we defined the mock object itself as a private inner class of the test class -- often a convenient approach because it is clearer to put the mock right next to the test code that uses it, and because inner classes have access to the instance variables of their surrounding class. |
| www-106.ibm.com /developerworks/library/j-mocktest.html (2350 words) |
|