As a side effect, the new adapter class will have only the methods you
need, in case the class you cannot change has a bigger interface.
Cheers,
/Manuel
The only way I know to do that is not using mocks, sorry. What helped
me in the past is Michael Feather's book "Working Effectively with
Legacy Code" (http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052),
which has many detailed examples / patterns how to test code with
minimal changes.
Cheers,
/Manuel
Isolator++
*http://www.typemock.com/isolatorpp-product-page*
RudeMocks
http://www.martinecker.com/wiki/index.php?title=RudeMocks/Introduction
http://www.parasoft.com/jsp/products/cpptest.jsp
Modifying code to make it testable (done in the right way) also makes
the code better-designed: more modular, explicit dependencies instead
of implicit dependencies, classes and methods that don't violate the
Single Responsibility Principle. And it's relatively free. Some of the
solutions above cost a lot of money.
Of course, the same programmer who wrote or modified the code should
be testing it, otherwise they are not learning how much damage their
poor design does to testability.
--
C. Keith Ray
Web: http://industriallogic.com
Twitter: @CKeithRay, @IndustrialLogic
Amplify Your Agility
Coaching | Training | Assessment | eLearning