I just created a `Manager` that deals with a `SuperClass` that is extended all over the code base and registered with some sort of `SuperClassManager` (`SCM`).

Now I would like to test my `Manager` that is aware of only the `SuperClass`. I tried to create a concrete `SCM`, however, that depends on a third party library and therefore I failed to do that in my jUnit test. Now the option is to mock all instances of this `SCM`. 

All is good until now, however, when my `Manager` deals with the `SCM`, it returns children of the `SuperClass` that my `Manager` does not know or care about. Nevertheless, the identities of these children are **vital** for my tests (for equality, etc.).

Since I cannot use the concrete `SCM`, I have to mock the results of calls to the appropriate functions of the `SCM`, however, this means that my tests and (indirectly) my `Manager` need to know and care about the children of the `SuperClass`. 

Checking the code base, there does not seem to be a more appropriate location for my test (that already maintains the appropriate real dependencies).

**Is it worth it** to introduce unnecessary dependencies for the sake of unit testing?

---

**Update 18/DEC/2012**

---

Here is a simplified version of my problem:

```
package some.package.declaration;

import some.open.source.framework.TopComponent;
import some.open.source.framework.WindowManager;

/**
 * Own source code.
 * Knows WindowManager and TopComponent; but no
 * direct child of TopComponent.
 */
class TopComponentManager{

  /**
   *
   */
  void efficientlyDoOperationsOnCurrentTopComponents(){
    Set<TopComponent> currentTopComponents = get all current TopComponents from WindowManager;
    Set<TopComponent> getNeededTopComponents(currentTopComponents);
    do some operations on the current TopComponents;
    ...
    ...
  }

  void Set<TopComponent> getNeededTopComponents(Set<TopComponent> givenTopComponents){
    Set<TopComponent> neededTopComponents = new HashSet<TopComponent>(givenTopComponents);
    disregard and keep some TopComponents based on controls;
    return neededTopComponents;
  }

}

package some.package.declaration.test;   // same project as TopComponentManager

import jmockit;
import some.open.source.framework.TopComponent;
import some.open.source.framework.WindowManager;

import own.source.code.childrenOfTopComponent.ChildTopComponent;  // Don't want to; need to introduce package dependencies
import own.source.code.childrenOfTopComponent.AnotherChildTopComponent;  // Don't want to; need to introduce package dependencies

class TopComponentManagerTest{

  @Tested
  TopComponentManager _topComponentManager;
  @Mocked
  WindowManager _windowManager;
  @Mocked
  ChildTopComponent _childTopComponent1;  //extends TopComponent; unknown to both TopComponentManager and TopComponentManagerTest
  @Mocked
  AnotherChildTopComponent _childTopComponent2;  //extends TopComponent; unknown to both TopComponentManager and TopComponentManagerTest

  Set<TopComponent> _currentTopComponents = new HashSet<TopComponent>();

  @Before
  void setUp() throws Exception {
    _currentTopComponents.add(_childTopComponent1);
    _currentTopComponents.add(_childTopComponent2);
  }

  void testgetNeededTopComponents(){

    Deencapsulation.invoke(_topComponentManager, "getNeededTopComponents", _currentTopComponents);

    new Verifications(){{
      verify that only _childTopComponent2 is returned;
    }};

  }

}

```

As can be seen, while testing the TopComponentManager, I have to verify the determined necessary elements which are unknown at this package.