Andrew,

> -----Original Message-----
> From: Andrew Arrow [mailto:[EMAIL PROTECTED]]
> Sent: 18 February 2002 23:12
> To: [EMAIL PROTECTED]
> Subject: sample cactus
> 
> I see the advantages of JUnit testing.  I read the JUnit example of
> writing a Foreign Currency Money Exchange program and the principles
make
> sense.  But in the Servlet JSP envionment I'm not clear on how it
helps.
> Am I supposed to setup elaborate senerios where I add variables to an
> HttpServletRequest variable and then check the returned HTML to make
sure
> the generated HTML is what I expected?
> 

No. The advantage is exactly the same as JUnit testing, except you
cannot easily perform JUnit testing on servlet code, nor taglib code,
nor filter code, nor some EJB code (like local interfaces or using
container services), etc. Why ? Because JUnit executes on the client
side (i.e. not in the container) and thus do not have access to these
objects. 

Cactus is actually a very simple proxy that let you execute your code in
the container and thus benefit from :

- real container objects
- integration unit testing : you're actually testing that your
application runs fine in your target container(s)

For more info, see http://jakarta.apache.org/cactus/index.html.

There is a complementary/concurrent strategy to Cactus which is called
Mock Objects (see http://jakarta.apache.org/cactus/mockobjects.html).

Now WRT your specific questions, Cactus also integrates with HttpUnit to
let you perform some functional testing, like checking returned HTML
from a JSP but this is not the core of Cactus. It should rather been
seen as a nice extension that let you test your code form a single
framework. You do not have to use this feature. If you're only after
testing JSP pages, I would suggest you only use HttpUnit (there is no
need for Cactus).

> I downloaded the latest version of Cactus, but the example included
seem
> to test cactus itself.  I was expecting an example that showed how to
> create my own tests that prove my JSP Servlet application's logic is
> working.  Do you have some sample Cactus tests you've written I could
see?
> 

Actually, there are several examples of Cactus in action in the samples
: look for package org.apache.cactus.sample.* (package
org.apache.cactus.sample.unit.* contain unit tests to unit test Cactus
itself as you have noticed - However, Cactus is using Cactus to test
itself, so it is not really different from what you would write in your
own test case).

> Thanks.
> 
> -Andrew
> 
> 

-Vincent

> 
> 
> Andrew Arrow
> Meritage Technologies
> [EMAIL PROTECTED]
> http://www.meritagetech.com



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to