I am developing an app that relies heavily on an external dll, my app needs to support new versions of the dll as well as being backwards compatible with the old ones.
Are there any good ways to have my unit tests target all of these different dll versions without the need to rewrite the tests as soon as a new version of the api is released? How is this best handled?
Thanks!
Write an Adapter or Facade that wraps the external DLL. Make it implement an interface IExternalDLL (of course choose a better name), which documents/specifies your needs from the external DLL ; it does not have to exactly mimic the function signatures of the actual implementation.
Write up a set of 'contract tests' against the interface, the way you expect the interface to work.
Now you can write different adapters per new version - in case of some breaking changes from v1 to v2. Your client is abstracted due to the interface.. Its the job of the adapter/facade to make sure the corresponding version of the dll meets the contract tests. You write one set of tests and exercise it with all implementations of the adapter/facade. The next time a new version is rolled out - you can
If you are using nant, team build or similar you could xcopy the lib binary to the folder which your test project fetches its binaries from before running the tests.
Pseudo example:
This is pretty simple and should be easy to try out. Note: "The write an adapter or facade" answer is the preferred way of making your program work against different version so do that too, I'm just talking about actually testing against multiple versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With