From: Barry K. <bk...@in...> - 2003-05-21 20:21:52
|
I've run into a problem which I do not [yet] know how to solve. I am testing an abstract class. Specifically, I am testing that the framework protocol is being adhered to. One of the means to do this is to test the that the abstract class invoke the appropriate abstract methods correctly. In 0.8, I did something like: private static AbstractClassUnderTest extends AbstractClass { public CallSequence expectedAbstractMethod = ... // was abstract in AbstraceClass protected void abstractMethod(Object foo) { expectedAbstractMethod.call(...); } } Now the tests can create an AbstractClassUnderTest, testing that the concrete methods invoke abstractMethod() correctly. With 0.9, CallSequence requires a Mock in its call() method. But I cannot create a Mock because the abstractMethod() does not appear on any interface. One solution is to create an interface within the test class that just contains abstractMethod() so that a Mock can be created to satisfy CallSequence. Another solution is to refactor the abstract methods into a strategy interface, but I don't really want to that large of a design change just to upgrade to 0.9. Is there any way that anybody can think of? Is this a missing use case for dynamocks (ie, support for testing abstract classes)? |