From: Nat P. <nat...@b1...> - 2003-06-19 08:25:46
|
From: "Eli Tucker" <sou...@ne...> > Are DynaMocks for use only with interfaces? If so, it sure would be > nice to have a DynaInterface that is generated on the fly from a class. At the moment yes, because of limitations of the java.lang.reflect.Proxy class. Generating mocks that extend real classes causes a number of tricky issues. For example, what should mocks pass as arguments to constructors of the base class? What if the constructor of the base class does "real" work, that you don't want to happen at test time? Automatically generating an interface from a class would not work because the mock must be interchangeable with the class to be mocked at compile time. So, if you want to mock an existing class I would recommend changing the design of that class so that it follows interface/implementation separation and then using the dynamic mocks. If you don't want to do that, you can write a mock by hand using the core com.mockobjects classes. > Also, is there any more information about DynaMocks available besides > what is shown on the wiki at these locations? > > http://www.mockobjects.com/wiki/SimpleServletTest > http://www.mockobjects.com/wiki/DynamicMockObjects There are also the unit tests in the test.mockobjects.dynamic package. On the wiki, you can also read: http://www.mockobjects.com/wiki/InterestingThreadsFromTheMailingLists Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 |