Suppose you have a class Foo with a private member of type Bar. You do not want users to know that the Foo implementation contains a panel, and you do not want users to create their own bar and pass it through the Foo constructor, any other method or configuration file.
Edit: The bar is also problematic in that it accesses resources that are independent of your test environment, such as a special database, network connection, or other process.
What do you do when you want to be able to unit test Foo? Is dependency injection possible? Does this mean that Bar and Foo are too closely related (although dependency is one way) and that this situation is never acceptable?
source
share