OK, I'll take a stab at this one.
In your first point (complex interrelations), I feel the confusion comes because you don't mention the creation of mockups to help you with the testing. The feeling that you need to implement the whole system just to test a small part of it is one of the biggest hold-ups to implementing a unit test strategy. The ice-breaker for this is to grok that unit testing is not just about writing a series of method calls and asserts, but about producing some test code which will test the internals of your real code for you, however that needs to be done.
In the case you describe where a chunk of the complete system will have, for example: a class which we want to test; a method of that class requires a factory which generates objects of classes which implement an interface, and maybe a few other misc objects.
A factory which doesn't use an interface, but generates objects descended from a (maybe abstract) base class is usually a bad design decision, becaue it is much harder to test, so I'll assume that you use an interface. If you don't, then converting shouldn't be too hard. Step one in unit testing this scenario is to write some basic unit tests for the interface used by the factory and its methods then create a mock class which implements the interface and passes the tests. Then write some tests for the factory class, and produce a mock factory which passes them by producing the mock objects written earlier. You can now write tests for classes and methods which require a factory, and give them the mock factory to work with. Similarly for any other objects needed by the method under test.
For your second point, the use of what I call "crash-test dummies" rather than just simple mockups is usually more appropriate. Consider a modern crash-test dummy. It sits in the vehicle under test, packed full of sensors and connected to an array of data-logging and decision making gear. When building and testing a framework, these are vital pieces of equipment. I'll take a very simple container framework as an example, but most dynamic frameworks are usually amenable to the same approach.
Stage one, of course, is to write some tests for the operation of your crash-test dummy. You are going to rely on its results later, so it's vital to trust it. Imagine all contained classes implement the following simple interface:
Following my points above, the first step is to create a mock ActionContext (I'll skip the tests for it, it's pretty self-contained, so they are not hard to do):
Not that contrary to my usual practice, the member variables are all public. This class is designed solely for testing, so I deliberately make its internals visible to the test harness. Note also that the "real" Action may end up very similar to this (although probably with private members) but I am deliberately ignoring thinking about that now. That's a different story, for later. One thing at a time.
Now we can write a very simple dummy Action:
At the moment, this is still just a "Mock", rather than a "Dummy". In order to make it more useful, we need to decide on the kind of "instrumentation" we need. In this case I'll cut to the chase and add a few methods, but in the real world you'd need to spend some thought and develop these as you go along writing your tests.
The tests might include (I've omitted the JUnit preamble)
and a class which passes these tests might look like
Why is all this useful? Well, we can now test the framework, and look "inside" the dummy at each step to make sure things are working OK. Imagine a very simple framework which has a few operations - 1. add an Action and call its init method with the current context, 2. process a
String, passing it to each action in turn and returning true if any of the actions returned true, 3. remove a specified action, 4. remove all actions. I won't go into great detail here, as your framework will no doubt be different, but consider the following unit test examples:
This may have been a bit rambling, but I hope you get the idea of unit testing frameworks using mock classes and instrumented dummy objects.
Has it helped at all?