Unit-testing code that relies on untestable 3rd party code
Posted
by
DudeOnRock
on Programmers
See other posts from Programmers
or by DudeOnRock
Published on 2013-11-06T02:31:55Z
Indexed on
2013/11/06
4:16 UTC
Read the original article
Hit count: 272
unit-testing
Sometimes, especially when working with third party code, I write unit-test specific code in my production code. This happens when third party code uses singletons, relies on constants, accesses the file-system/a resource I don't want to access in a test situation, or overuses inheritance. The form my unit-test specific code takes is usually the following:
if (accessing or importing a certain resource fails)
I assume this is a test case and load a mock object
Is this poor form, and if it is, what is normally done when writing tests for code that uses untestable third party code?
© Programmers or respective owner