Thanks Vincent
This is what I did with HttpUnit

* Set the parameters for page 1 like Username and Password ( Login
example )
* Simulated Submit operation and got the response object ( I use the
SubmitButton method provided by httpunit)
* But the response object still contained the first page details only
when I was expecting an altogether different page depending on the login
validation

What am I doing wrong ? Or am I expecting too much from httpunit ? What
the response object should contain after submit ???

What I wnat to see in the response object is the details of the
resulting page.

Thanks
Anand



-----Original Message-----
From: Vincent Massol [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 29, 2001 4:27 PM
To: [EMAIL PROTECTED]
Subject: Re: Navigating Login


Anand,

There are different kind of tests : unit tests, functional tests,
acceptance
tests, system integration tests ...
It seems to me that you want to consider your login/submit process as a
black box and don't care if it works internally but rather want to test
on
the resulting page. If this is the case, use HttpUnit. If you want to do
finer grained tests, like unit tests, go for Cactus.

In cactus, you would write something like the example I have provided in
my
previous post.
-Vincent

----- Original Message -----
From: "Anand Mohanram" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 29, 2001 11:29 AM
Subject: RE: Navigating Login


Hi Vincent

As an extension to this,how do I test the Submit functionality of a page
?
I want to set parameters for various controls and I do a Submit or an
OK. I want to test whether the resulting page is displayed correctly.

Login page could be an example.
On Submit,I send the parameters to a Servlet.

Thanks
Anand

-----Original Message-----
From: Vincent Massol [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 29, 2001 2:30 PM
To: [EMAIL PROTECTED]
Subject: Re: Navigating Login



----- Original Message -----
From: "Ranjan Bagchi" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 29, 2001 9:50 AM
Subject: Re: Navigating Login


> Hi Vincent --
>
> That's a good observation:  I'm trying to get the differences between
HttpUnit
> and Cactus sorted out, and I'm starting to come around with the notion
that for
> existing code, I may be stuck with HttpUnit, but for newer stuff I've
got
the
> opportunity to design it so that Cactus can test it.
>

It is very simple :
* if you need only functional testing (ie. black box testing), use
HttpUnit
* if need only unit testing (white box testing) use Cactus
* if you need both unit testing and functional testing you can also use
Cactus as it integrate with HttpUnit for asserting resulting pages but
won't
help for requests (like https, ...)

> The bit navigating login is because I'm trying to get the Request and
Session
> objects set up as if an actual user had logged in.. But, am I right in
my
belief
> that that's much more of an HttpUnit thing?

not sure to understand ... ! If you wish to test that your Session
objects
and request are correctly set up, you should definitely use Cactus as
HttpUnit won't help you there.

>
> Thanks again,
>
> Ranjan Bagchi
>
-Vincent

> Vincent Massol wrote:
>
> > ----- Original Message -----
> > From: "Ranjan Bagchi" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Tuesday, August 28, 2001 8:04 PM
> > Subject: Navigating Login
> >
> > > Thanks, Vincent and Jari for helping me get started:
> > >
> > > I added the cactus .jar files to my regular classpath and am able
to
see
> > > my .jsp files and (and dispatch to them).
> > >
> > > I'm still trying to figure out how to test login:  the app I'm
adding
> > > tests for wasn't exactly designed for this kind of testing, so
> > > authentication and such aren't called out in functions which I can
call
> > > server-side.
> > >
> > > Rather, I get a form with an https: action param which
authenticates
and
> > > sets all sorts of server-side properties. (Actually, this seems
fairly
> > > normal for an app built on top of weblogic commerce server).
> > >
> > > I'm guessing that the right approach would be to just navigate
through
the
> > > right forms, setting the appropriate params and getting my session
set
up
> > > as expected.  How would I do this using Cactus?   Has anyone else
> > > navigated through WLCS login?
> > >
> >
> > Cactus should be used for unit tests. You seem to use the verb
"navigate" a
> > lot which would imply performing functional tests and not unit
tests. Is
> > that what you wish to do ? If this is the case, you should probably
use
a
> > tool like HttpUnit. On the other hand, if you're looking to unit
test
> > *methods* of your code, then Cactus is the right tool.
> >
> > I have used WLCS and WLPS in the past and I remember that it
provides a
> > great amount of custom tags that you can put in your JSPs to perform
> > authentication for example. When you use WLCS you are very much
tempted
to
> > put your logic in the JSPs. I would however recommend, to rather use
a
> > controller (either the one they provide (WebFlow I seem to remember
was
the
> > name) or Struts or any other) and code Actions (I can't remember how
they
> > are called in WebFlow, Pipeline or something like this) that perform
logic.
> > For example you would say that before such and such actions you'll
call
the
> > LoginAction to authenticate the user and set up session properties
and
the
> > like and then you'll call another action, ... All WLCS tags are
actually
> > wrappers around java classes that you can call directly from your
code.
> >
> > If you decide to keep using the custom JSP tags, what you could do
is do
> > something like :
> >
> > public class TestMy extends ServletTestCase
> > {
> >   public void testXXX()
> >   {
> >
config.getServletContext().getRequestDispatcher("/myjsptotest.jsp");
> >
> >     // make necessary asserts on sessions, context, ...
> >   }
> >
> >   public void endXXX()
> >   {
> >      // perform some validation on the returned content if need be
> >   }
> > }
> >
> > However, I believe that this where Cactus unit testing can help you
write
> > better code in that I don't believe it is good practice to use
custom
tags
> > that performs actions in your JSPs. Custom tags in JSPs should be
used
only
> > to retrieve data and actions should rather be handled by a
controller.
> >
> > > Thanks,
> > >
> > > Ranjan Bagchi
> > -Vincent
>
>



Reply via email to