From: Mickael V. <mv...@ge...> - 2003-12-03 17:16:46
|
Hi everybody, I'm new to mockobjects and I try to understand to right way to use them. What I understound of mockobjects is that the good way to use them is to know which interactions it will have with your tested object , then make your mockobject respond to the tested object requests and record them, at the end of the test check that what has been recorded is correct. Is it true ? Is it so important to test interactions with mockobjects if your tested method returns the values you expected ? Is it correct sometimes to put code in your mockobject that does the same as the object it replaces instead of returning values. Sometimes it may be easier to code the functionnality than to emulate responses. In my case I test services called from a servlet, so I manipulate HttpRequest, HttpSession, ServletContext ... which I replaced with mockobjects. In this case I find it easier to code in the MockHttpSession the setAttribute and getAttribute methods than to guess which values will be asked if the service puts a lot of objects in the session and remove them. One service called by the servlet may have a lot of interactions with mockobjects and I can't use real objects as I don't have implementations. Do you think it is an acceptable use of mockobjects ? Or did I miss something ? I don't want to use Cactus which forces me to deploy. Maybe my use of mockobjects is too close to the the simulation of a web container ? Mickael |