Hi,

> -----Original Message-----
> From: Dos Santos [mailto:[EMAIL PROTECTED]]
> Sent: 28 February 2002 14:42
> To: [EMAIL PROTECTED]
> Subject: Functional testing with container interaction
> 
> I have read in several places including this mailing
> list, that in order to do sequential testing of
> servlets one would have to use a functional testing
> framework such as httpunit. 

It depends. Cactus, in the current version, only lets you test one HTTP
request and one HTTP response. Thus :

* if your servlets call each other using forwards it works fine with
Cactus,
* if your servlets call each other using redirects (i.e. different HTTP
requests/responses), then Cactus will let you test each request/response
with several test cases. That is, in each test case, you'll set the
conditions to be the same as the result from the previous servlet call
(i.e. correct HTTP parameters, correct HTTP headers and correct
cookies). It is easy to set this with Cactus. BTW, as you're able to
test each request/response independently of the whole use case, you are
also able to test failure conditions quite easily (i.e. what happens if
the second servlet does not receive needed HTTP parameters for example),
which is not the case at all if you're doing functional black box
testing.

I believe Cactus is well adapted for unit testing servlets that call
each other. However it is not meant to be used as a black box testing
framework. If you wan to do this, then you need something like HttpUnit.

> The problem that I have
> with that is that I also want to test the integration
> of my application with the container and not use an
> emulator as such frameworks do.
> 

I'm not sure I understand what you mean by "emulator". If you use
HttpUnit for example, you simply send an HTTP request and you receive an
HTTP response and there is no emulator whatsoever.

Oh, I think I understand. What you mean is that you actually want to
unit test your application, right ? Functional black box testing *does*
test the integration with the container (your code is run in the
container).

> The application that I would like to test is comprised
> of servlets that call other servlets. It consists of a
> series of registration forms and if the client
> registers successfully she gets redirected to a
> specific URL. The idea is to test this aforementioned
> process and compare the final URL to see if this
> process is working under certain given circumstances.

Yes, but you also need to test the result from each step right ? Cactus
will let you do what you want, except it won't be seen as a single test
case but rather several. It will give more fine-grained tests, which may
or may not be what you want.

> 
> Could you please tell me where I can find more
> information on the subject and if you know of any
> framework that would supply me with tools to develop
> such tests.

You have to decide first whether you want to perform unit testing (aka
white box testing) or functional testing (aka black box testing). The
only framework that almost does both that I know of is Cactus. 

BTW it is quite easy to modify Cactus to do exactly what you want (one
HTTP request in, several redirects and one response). It seems several
persons are interested by this feature. For the moment we have
voluntarily turned of followRedirects in Cactus.

As this feature is being asked more and more I think we should probably
offer an API to follow redirects. Something like
WebRequest.setFollowRedirects(Boolean), with false being the default
value.

> 
> Thanks in advance for your help.

Thanks
-Vincent

> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Greetings - Send FREE e-cards for every occasion!
> http://greetings.yahoo.com
> 
> --
> To unsubscribe, e-mail:   <mailto:cactus-user-
> [EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:cactus-user-
> [EMAIL PROTECTED]>
> 




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

Reply via email to