----- Original Message -----
From: "Peter Donald" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, May 13, 2001 2:54 AM
Subject: Re: Mock Objects vs In-Container/Cactus


> Hi,
>
> At 01:21  12/5/01 +0100, Vincent Massol wrote:
> >It is available on the Cactus web site at :
> >http://jakarta.apache.org/commons/cactus/mockobjects.html
> >
> >I would very much like to have your opinion on that subject. If I receive
a
> >lot of positive answers, it might mean that we'll change the way Cactus
work
> >in order to do it the Mock Object way. As this is a big change, I'd like
to
> >have your opinion on that.
>
> Sorry I don't know enough about Cactus to have an opinion on that but I
> have found Mock Objects useful in the past - for somethings. (Though I
> never used the term MockObject).
>
> The only problem I founf that is overtime you can end up creating a
virtual
> container. With one of my projects I found that my "Mock Container" ended
> up being just a lightweight container - way beyond what it should have
been
> doing.
>

I have some answers for that ..
* first, you should only implement mock objects that you need, meaning if
you are testing servlet (which has maybe more than 100 methods) you only
actually need to implement the methods that you use (i.e. about 10). So, you
throw a NotImplemented exception for the methods you don't implement.
Whenever you need a new one, you just refactor your mock code, adding this
new method
* The implementation of the mock objects should be limited to getters and
setters. There should really be no logic (or minimum). If there is it means
there is a pb witht the mock object and it needs refactoring
* Providing a generic mock implementation of a container will lower the
initial cost of using Mock Objects. As I said in the article, there are 3
kinds of libraries that a generic mock framework could provide : the core
library + mock standard API libraries (Servlet, Taglib, ...) + mock
application specific API libraries (Struts, Turbine, Ant, ...). For example,
implementing a mock Servlet container only takes about 15K and is really
simple to do

But I agree with you ... That was basically my point when I was introduced
to Mock Objects last week ... :)
I still agree that using Mock Objects correctly require some methodology and
discipline.

> Cheers,
>
> Pete
>

Thanks
Vincent.


Reply via email to