I used test-driven-development followed by some re-factoring and ended up with a set of classes using composition to progressively increase type-specificity. For example:

* EventDispatcher -> TypedEventDispatcher -> FooEventDispatcher
* EventDispatcher -> TypedEventDispatcher -> BarEventDispatcher

So EventDispatcher dispatches generic events (String, Number, Object), TypedEventDispatcher only dispatches events based on objects, and FooEventDispatcher only dispatches Foo events, BarEventDispatcher dispatches Bar events and so on. 

The tests for all classes have identical behaviour, the only difference is the object type which is tested against. I have found that when I want to add a new event type I end up with the same test code as for the other classes.

This amount of duplication is obviously wrong. The resulting tests are quite fragile, as when I add a new feature to TypedEventDispatcher, I need to add the same tests to any objects which use it.

In Java, .NET, or Haxe I would be to create a generic type and test against that, however I am using ActionScript which does not support generics which is why I need a new class for each type to maintain type-safety.

As far as I can see, my options are:

1. Keep create the same tests for each new class.
2. Ignore the tests for derived classes, just create the new classes and assume they work.

Option #1 appears to the most "correct", but also results in fragile tests. Option #2 makes sense in that base object (TypedEventDispatcher) is tested so the derived classes should still work.

So my question is, what is the TDD philosophy for motivating creating new classes based on composition?

Update:
To ask the question in a different way, is it normal to end up with duplicate test code when deriving functionality from existing code?

Update:

BaseEventDispatcher test:

```
class BaseEventDispatcherTest {
    protected function test_dispatchEvent(dispatcher:Object, event:*):void {
        dispatcher.dispatch(event);
        assertEventDispatched(event)
    }
}

```

TypedEventDispatcher test:

```
class TypedEventDispatcherTest extends BaseEventDispatcherTest {
    [Test]
    public function dispatchEvent_TypedEvent_should_dispatch_event():void {
        var event:TypedEvent = new TypedEvent();
        test_dispatchEvent(dispatcher, event);
    }
}

```

FooEventDispatcher test:

```
class FooEventDispatcherTest extends BaseEventDispatcherTest {
    [Test]
    public function dispatchEvent_FooEvent_should_dispatch_event():void {
        var event:FooEvent = new FooEvent();
        test_dispatchEvent(dispatcher, event);
    }
}

```