From: Lucas F. <lu...@ha...> - 2001-09-14 18:26:10
|
Up to now I'm just reading about all that, and maybe I have missed something, but: Why creating, handling, refactoring all those MockObjects when there is such a thing as EasyMock? (Writing an interface if there is none is not the point I guess.) What are the disadvantages in using EasyMock? Or, what are the advantages in having the "real mock object" at hand? Thank you, Lucas |
From: Vincent M. <vm...@oc...> - 2001-09-14 20:13:27
|
----- Original Message ----- From: "Lucas Filz" <lu...@ha...> To: <moc...@li...> Sent: Friday, September 14, 2001 7:31 PM Subject: [Mockobjects-java-users] EasyMock vs. MockObjects > Up to now I'm just reading about all that, and maybe I have missed something, > but: > > Why creating, handling, refactoring all those MockObjects when there is such a > thing as EasyMock? (Writing an interface if there is none is not the point I > guess.) > > What are the disadvantages in using EasyMock? > > Or, what are the advantages in having the "real mock object" at hand? > The short answer is : the two methods (dynamic and static) are complementary. Why ? Because it is not always possible to generate good mock implementations. I'll give a simple example. Lets imagine you want to use a mock implementation of ServletOutputStream because you'd like to assert the result from an HTTP response. This class only has print() methods but no getter to access the content. Also what you'd like to do is to assert the full string that has been written to the stream and not byte by byte. This requires some intelligence that cannot be implemented automatically by EasyMock or a static generation (MockMaker). You'll also find that you'll discover patterns in your test case and you'll want to factorise these patterns in the mock objects to provide consistency of checks and easier writing of tests. Now, it probably depends on the kind of API you are mocking and some will be easily mocked with EasyMock. Others won't. I guess that a practice would be to use automatic generation (be it dynamic or static) and then manually write or modify the mocks (for those statically generated). Thus, the problem is that EasyMock or MockMaker won't provide in-the-box and ready to use mock objects (some will need to be written by hand or modified). The idea of the Mock Objects project is twofold : provide a core framework of expectations and useful classes for writing mock implementations (This framework is actually used by MockMaker to generate mock objects and it could be used by EasyMock too) and some prepackaged and already written mock implementations for some standard APIs. The idea is that these API will be feature complete (ok, I agree, there is still some work to be done ... :) ) and will have been fine tuned to already provide the patterns I mentionned above (i.e. shortcuts for easy testing). Tell me what you think. I'd like to hear from others too. Thanks -Vincent Massol |
From: Lucas F. <lu...@ha...> - 2001-09-15 14:33:51
|
Thank you Vincent & Steve for your answers! I see your points. Especially the standard API mocks! Are there more than the ones in mockobjects.jar? (some /io, /servlet, /sql as far as I remember). Are there already some more somewhere? Tim told me at XP2001 that he/you have already mocked javamail. Is that available? Another point I see is that in using EasyMock there rests some 'kind of magic', whereas the real mocks are simple and everything is there to inspect. Maybe easier for a newcomer too. Of course, convergence of the two (dynamic / static) in naming and usage would be fine, as it would give me freedom using both in the same project. (I would not dare now.) > The idea of the Mock Objects project is twofold : provide a core framework > of expectations and useful classes for writing mock implementations (This > framework is actually used by MockMaker to generate mock objects and it > could be used by EasyMock too) why isn't that the case? Has somebody talked to EasyMock-Tammo Freese already? Steve: > That said, there are now several tools based around mock objects and it > seems like it would be a good idea to attempt some convergence. Any > offers? you mean founding the MOMG ? What I can offer is 'opening the discussion'. By the.s way, what in detail needs to be done for the open task: > Write a common coding and naming convention (for example names > of mock initialization methods like setupAddParameter(), name of methods > for setting expectations, ...) and reformat all the existing code. Sounds like there are naming inconsistencies in mockobjects.jar. Is there a list of the methods needing proper naming? Nice weekend, Lucas Lucas Filz A-1140 Vienna +43.1.577 1 899 |
From: Olaf K. <ok...@ab...> - 2001-09-15 15:20:25
|
Hi, Apologies to those, who already know: We just released "yet another" mock generator, the MockCreator, this one is tightly integrated with Visual Age for Java. (see http://www.abstrakt.de/mockcreator/mockcreator.en.html for details and download). It's free (license is GNU: GPL and LGPL) (This announcement was made on behalf of Christian, who has done almost all of the work) We headed for our own way because we wanted the generator integrated in VAJ (thus no MockMaker) couldn't use EasyMock (because of Java 1.2 in VAJ). We'd be happy to get some feedback on the MockCreator. btw: It makes good use of the mockobjects.jar implementation in the generated classes (especially the collections). Have a nice weekend, Olaf -- abstrakt gmbh Behringstrasse 16b (neu!) 22765 Hamburg Tel: +49-40-39804630 (neu!) Fax: +49-40-39907669 http://www.abstrakt.de/ Wir sind umgezogen. Bitte beachten Sie die neue Adresse + Telefonnummer |
From: Steve F. <st...@m3...> - 2001-09-17 00:44:13
|
RnJvbTog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0KPiA+IG9m IG1vY2sgaW5pdGlhbGl6YXRpb24gbWV0aG9kcyBsaWtlIHNldHVwQWRkUGFyYW1ldGVyKCksIG5h bWUgb2YgbWV0aG9kcyANCj4gPiBmb3Igc2V0dGluZyBleHBlY3RhdGlvbnMsIC4uLikgYW5kIHJl Zm9ybWF0IGFsbCB0aGUgZXhpc3RpbmcgY29kZS4NCj4gDQo+IFNvdW5kcyBsaWtlIHRoZXJlIGFy ZSBuYW1pbmcgaW5jb25zaXN0ZW5jaWVzIGluIG1vY2tvYmplY3RzLmphci4NCg0KbW9zdCBsaWtl bHkuIFNvbWUgb2YgdGhlIGNsYXNzZXMgaGF2ZW4ndCBiZWVuIGNoYW5nZWQgaW4gYSB3aGlsZS4N Cg0KPiBJcyB0aGVyZSBhIGxpc3Qgb2YgdGhlIG1ldGhvZHMgbmVlZGluZyBwcm9wZXIgbmFtaW5n Pw0KDQpOby4gV2UgdGVuZCB0byBmaXggY29kZSBhcyB3ZSB0b3VjaCBpdC4gSWYgeW91IHdhbnQg dG8gZ2V0IGludm9sdmVkIHRoYXQgd291bGQgYmUgZ3JlYXQuDQoNClN0ZXZlDQoNCg0K |
From: Lucas F. <lu...@ha...> - 2001-09-17 12:12:55
|
> > Of course, convergence of the two (dynamic / static) in naming and usage would > > be fine, as it would give me freedom using both in the same project. (I would > > not dare now.) > > why not? Because I find the techniques too new in order to mix them. Here I think more of the other programmers, unfamiliar with all that, who eventually will have to work with the code, and keep it up to state. It could be too confusing at the first glance, EasyMock and real mockObjects. In this sense, I would now try to stick to one of the two techniques. But this will change, as mock-test-programming becomes an industry-standard. in some years. > No. We tend to fix code as we touch it. If you want to get involved that would be great. I'll talk to you later about that, Steve. No time these days. Lucas |
From: Steve F. <st...@m3...> - 2001-09-14 21:57:45
|
RnVydGhlciB0byBWaW5jZW50J3MgcG9zdGluZy4NCg0KLSBzb21lIG9mIHVzIHdlcmUgc3R1Y2sg aW4gSmF2YSAxLjIgKHRoYW5rcyB0byBWaXN1YW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