----- Original Message -----
From: "Bob Davison" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 14, 2001 10:01 AM
Subject: Re: Mock Objects vs In-Container/Cactus
>
>
> Vincent,
>
> I have been using mock objects for a while and they are very useful but do
not
> invalidate the work that you have done so far. Before I heard about
Cactus I
> was about to write a mock servlet api implementation to allow me to test
my
> servlet and jsp code but hit the following issues:
>
> - who is going to compile my jsp's? I rely on the container to do it for
me
> and mock objets won't help.
correct but then Cactus does not provide unit testing of JSP either. Also, I
don't believe in unit testing JSPs. IMO, all logic should be delegated to
Taglibs so only the presentation code remains in the JSP. And presentation
code is testing using a functional test framework (like HttpUnit).
Note: You can always use an Ant jspc task (it uses Jasper, the Tomcat JSP
compiler) to compile the JSPs if you wish ...
> - who is going to handle includes and forwards? Again I rely on the
container
> to do this for me.
>
This can be handled by the Mock library. Now, it really depends if you want
to test full interaction between objects or simply unit tests a given
method. The later case can be done using Mock Objects but the former not so
easily ... and it might require some additional functional tests. Cactus is
providing a middle ground between rigorous fine grained unit tests and very
coarse-grained functional tests.
> I think that in-container and mock objects address different issues. At
one
> point you want to test your use of the servlet api and for that you need
mock
> objects. At another point your test relies upon some service that the
container
> provides and for that you need in-container.
>
> A mock servlet api implementation would be a great asset to Cactus and
would
> bring the added benefit that we could have many more unit tests for Cactus
> itself, which currently relies mainly on functional tests.
>
Yes, I agree. The real challenge is to ensure that the test writer only
writes it's tests cases once only and not once for the Mock objects and
another time for in-container ... If we can find a way of doing that, it
would be great I think ... :)
> Re. your pro/con section on the web page you mention the issue of adding
> flexibility into your app that is needed purely for testing and not for
> production use. This does seem to fly in the face of YAGNI and the
simplest
> thing that could possibly work but I don't think that it does, you do need
it to
> test things properly. And you have the added bonus that you end up with
> considerably more supple software.
>
yes, I do agree completely with this ...
> .../Bob
Vincent.