One of the biggest problems that currently keeps me from completely immersing myself in unit testing is that the really large percentage of the code that I write depends heavily on third-party COM objects from different sources, which also tend to interact with each other. with a friend (I am writing add-ons for Microsoft Office using several helper libraries if you need to know).
I know that I should probably use mock objects, but how exactly will I do this in this case? I see that this is relatively easy when I just need to pass a reference to an existing object, but some of my routines instantiate external COM objects and then sometimes pass them to another external COM object from another library.
What is the best approach? Should my test code temporarily change the COM registration information in the registry so that the tested code creates an instance of one of my mock objects? Should I introduce modified type library modules? What other approaches exist?
I would be especially grateful for examples or tools for Delphi, but would also be just as happy with more general tips and explanations of a higher level.
Thanks,
Oliver
unit-testing delphi mocking com
Oliver giesen
source share