You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by James Black <jb...@ieee.org> on 2003/12/25 01:02:33 UTC

re: unit testing a webapp that requires prior logging in

Hello,

  I am starting to work with cactus, as I have an application to unit test
that has various jsp pages and java classes in the classes directory.

 

  In order to do the tests the program needs to be logged into the
application framework first, and that causes me some difficulty.

  I know how to log in using httpunit, but I don't know how to use that
WebConversation instance for the rest of the unit test.

 

  How do I approach this?  I hope my question makes sense.

 

  Also, how do I integrate in the strutsunittest framework with cactus, or
do I need to use different frameworks for the different parts? It would seem
that I use httpunit to test the browser side, strutsunit for all of the
forms and cactus to test the parts that are called by the struts action
controller.

 

  Thank you for your response.

 

"If a man does not keep pace with his companions, perhaps it is because he
hears a different drummer.  Let him step to the music which he hears,
however measured and far away." - Henry David Thoreau 

 


Re: unit testing a webapp that requires prior logging in

Posted by Mark Lybarger <ma...@wideopenwest.com>.
James,

Cactus is a testing framework for testing j2ee components servlet, ejb 
and jsp (pseudo servlet). It's strength is that it provides integration 
testing where the tests run in the container, and your j2ee component 
recieves all the services that the container provides. 

James Black wrote:

>Hello,
>
>  I am starting to work with cactus, as I have an application to unit test
>that has various jsp pages and java classes in the classes directory.
>
> 
>
>  In order to do the tests the program needs to be logged into the
>application framework first, and that causes me some difficulty.
>
>  I know how to log in using httpunit, but I don't know how to use that
>WebConversation instance for the rest of the unit test.
>  
>
HttpUnit is a great developer oriented unit testing framework for 
testing application use case scenerios.  IIRC, this is typically called 
black box testing, and generally provides the greatest "bang for your 
buck" with respect to one test per lines of code tested.

> 
>
>  How do I approach this?  I hope my question makes sense.
>
> 
>
>  Also, how do I integrate in the strutsunittest framework with cactus, or
>do I need to use different frameworks for the different parts? It would seem
>that I use httpunit to test the browser side, strutsunit for all of the
>forms and cactus to test the parts that are called by the struts action
>controller.
>  
>
In this instance, struts is the servlet and would be the object being 
tested.  I haven't used the struts framework and am not familiar with 
the strutsunit testing framwork.  I have used turbine, and we found 
HttpUnit to be much easier to test our action classes as well as our web 
interface.  We also used a mock object implementation for testing our 
turbine actions (which contained way too much business logic), but the 
mock object approach we used seemed to be way too much overkill.

> 
>
>  Thank you for your response.
>
> 
>
>"If a man does not keep pace with his companions, perhaps it is because he
>hears a different drummer.  Let him step to the music which he hears,
>however measured and far away." - Henry David Thoreau 
>
> 
>
>
>  
>



RE: unit testing a webapp that requires prior logging in

Posted by Vincent Massol <vm...@pivolis.com>.
Hi James,

You have to log your application in your test fixture. "Logging in"
depends on your framework. It may be as simple as setting an HTTP
session attribute.

-Vincent

> -----Original Message-----
> From: James Black [mailto:jblack@ieee.org]
> Sent: 25 December 2003 01:03
> To: cactus-user@jakarta.apache.org
> Subject: re: unit testing a webapp that requires prior logging in
> 
> Hello,
> 
>   I am starting to work with cactus, as I have an application to unit
test
> that has various jsp pages and java classes in the classes directory.
> 
> 
> 
>   In order to do the tests the program needs to be logged into the
> application framework first, and that causes me some difficulty.
> 
>   I know how to log in using httpunit, but I don't know how to use
that
> WebConversation instance for the rest of the unit test.
> 
> 
> 
>   How do I approach this?  I hope my question makes sense.
> 
> 
> 
>   Also, how do I integrate in the strutsunittest framework with
cactus, or
> do I need to use different frameworks for the different parts? It
would
> seem
> that I use httpunit to test the browser side, strutsunit for all of
the
> forms and cactus to test the parts that are called by the struts
action
> controller.
> 
> 
> 
>   Thank you for your response.
> 
> 
> 
> "If a man does not keep pace with his companions, perhaps it is
because he
> hears a different drummer.  Let him step to the music which he hears,
> however measured and far away." - Henry David Thoreau
> 
>