jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Coyner <guitarman_...@yahoo.com>
Subject RE: JSP testing, anybody?
Date Tue, 21 Jan 2003 15:59:19 GMT
> How do you use just JUnit?

As long as your code does not rely on any servlet/ JSP interfaces or classes
you "should" be able to test your code outside of a container. If you need the
interfaces or classes but do not need a full-blown container implementation
consider creating mock implementations of the interface or class to test and
verify exactly what you need.

---
Brian Coyner
Senior Software Engineer
Object Computing, Inc.
O'Reilly Author (Java Extreme Programming Cookbook - out in March 2003)



--- EPugh@upstate.com wrote:
> I still use Cactus though for other types of business logic.  Admittedly, I
> think my apps are too coupled to the database, but often I find I need all
> those bits of support that the container provides to test my business logic.
> 
> Good design says your BL should not be in JSP however.  
> 
> Eric
> 
> -----Original Message-----
> From: Olivier Gourment [mailto:ogourment@yahoo.com]
> Sent: Tuesday, January 21, 2003 10:45 AM
> To: Cactus Users List
> Subject: Re: JSP testing, anybody?
> 
> 
> 
> I agree that JSP testing is hard, but it also proves useful. If you
> design your tests not to be too dependent on the actual HTML content,
> then it works. I have used HTTPUnit, not Cactus, for this purpose.
> 
> Of course, it doesn't mean that you should put code in JSPs.
> 
>     Olivier
> 
> 
> --- Brian Coyner <guitarman_151@yahoo.com> wrote:
> > It's my opinion that testing JSPs is too hard, and therefore any
> > critical logic
> > in a JSP should be refactored to a standalone helper class. These
> > helper
> > classes can then be tested using JUnit (no need for Cactus). If you
> > find
> > yourself putting business logic into a JSP then you need to stop and
> > refactor
> > your code.
> > 
> > Brian 
> > 
> > 
> > --- "Frank J. Buono" <Frank.Buono@ExceptionalSoftware.com> wrote:
> > > All:
> > > Has anybody had any luck testing JSP's with Catus/WebLogic 
> > > per the suggested idea in the "Jsp Howto"(See Below)?
> > > Frank
> > >  
> > > public class MyTest extends ServletTestCase
> > > {
> > >     [...]
> > >     
> > >     public void testXXX()
> > >     {
> > >         RequestDispatcher rd = theConfig.getServletContext().
> > >             getRequestDispatcher("/path/to/test.jsp");
> > >         rd.forward(theRequest, theResponse);
> > >     }
> > >     
> > >     public void endXXX(WebResponse)
> > >     {
> > >         // Assert result
> > >         [...]
> > >     }
> > >     
> > >     [...]
> > > }        
> > > 
> > > 	 
> > > 
> > > 
> > 
> > > ATTACHMENT part 2 application/ms-tnef name=winmail.dat
> > > --
> > > To unsubscribe, e-mail:  
> > <mailto:cactus-user-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <mailto:cactus-user-help@jakarta.apache.org>
> > 
> > 
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> > http://mailplus.yahoo.com
> > 
> > --
> > To unsubscribe, e-mail:  
> > <mailto:cactus-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:cactus-user-help@jakarta.apache.org>
> > 
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
> 
> --
> To unsubscribe, e-mail:
> <mailto:cactus-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:cactus-user-help@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

Mime
View raw message