Hey folks, have a question regarding dependency injection
and 100% test coverage.
Suppose you have a function which itselfs calls some functions of a foreign package,
you definitely not want to be called in your tests. Let’s call them evil functions
for the sake of it.
The foreign package does not provide any struct or interfaces for those evil functions.
So you have to create your own interface with methods that act as wrappers for those “evil” functions.
Then you build two implementations of this interface: one for normal builds which
actually wrapp those evil functions. And a mocked version for your tests which do no harm.
So far this seems to be the normal thing to do (at least for what I have read so far),
but what about test coverage? You can achieve 100% test coverage on methods using
the interface, but you can’t get 100% on the interface implementation for the real
build, since those are calling those damn evil functions. You can’t test those functions
at all. No blog post I read covered this problem, sadly.
How do you handle cases like this?