From: Olaf K. <ok...@ab...> - 2002-06-27 17:40:13
|
Hi John, John Sisk wrote: > > Hi there, > > What is the best practice for integrating mocks into a project? The key point is to shift object creation from classes to be tested to somewhere outside. That doesn't necessarily meen a factory to be involved, but the class in question will be parameterized with their collaborators from somewhere outside (probably/sometimes in the constructor). This way production code constructs objects and parameterizes them with "real" collaborators (and may do so with the use of factories or builders). Testcode on the other hand directly creates objects under test and parameterizes them with MockObjects suiting its particular needs. Don't pollute factories with mockobjects. (That is - if you wanted to ask that and I understood correctly). Production code should be able to be delivered without any MockObject. Hope that helps? Olaf -- abstrakt gmbh, Behringstrasse 16b, 22765 Hamburg Tel: +49-40-39804630, Fax: +49-40-39804639 http://www.abstrakt.de/ |