Using MockLib, a tool that simulates entire APIs, you can unit test contracts or well-defined APIs and refactor whole components with very few changes to your tests.
by Dean Hiller
July 18, 2007
nit testing individual classes is almost always useless. You need to unit test contracts or well-defined APIs instead. Why? Because testing and simulating APIs enables you to refactor a whole component with very few changes to the test. You can even rewrite the entire component without the tests knowing, since the tests depend only on the APIs they use and the APIs they simulate. They don't depend on any implementation classes.
This article introduces MockLib, a tool that simulates entire APIs (not just one single interface) using a mock library. It enables you to perform this more effective type of unit test. (If you have not read my first DevX article on Verifydesign, then you should read that first. Verifydesign helps you establish well-defined APIs.) Once you have cleaned up your projects so that implementations depend only on APIs, you are ready to start adding tests.
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!