I have been asked to unit test some legacy code.
Currently, the code is tightly coupled with a 3rd party library both in terms of method calls and types used.
My first thought is to stub the 3rd party library (using an appropriate mocking framework) such that I can easily test the code of interest rather than the 3rd party library. However, to do this, I need to refactor some of the code so that the code of interest is isolated from the external library dependency.
My initial thought was to extract an interface and use a wrapper to make calls to the library. However, to entirely decouple the library I need to remove library specific types too, not just the method calls e.g.
LibrarySpecificType[] myVar = wrappedLibrary.DoX();
Although I have wrapped my library call in the above example, it still returns a library specific type, so it is still somewhat coupled.
How do I get around this? What is the best strategy to refactor the code to enable this?
Thanks!
Aucun commentaire:
Enregistrer un commentaire