jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@octo.com>
Subject RE: Concatenating two cactus tests?
Date Fri, 22 Feb 2002 20:08:23 GMT

Cactus is about unit testing. Although it is able to do some functional
testing (through the use of the endXXX() method), it's goal is not test
functional use case but rather request/responses.

For example, let's imagine that you have a verify authentication use
case : you make a call to a controller servlet and this later verifies
if you're authenticated and if not does a redirect to a JSP page.

What you would test with Cactus is : Verify that the authenticateUser()
method is working. For that you would write the following tests :

1/ In one test, you would set to true the Session variable indicating
that the user is logged to true. Thus the authenticateUser() method
would forward to the requested page (let's say passed as an HTTP
parameter). In your endXXX() method you would verify that the returned
HTTP responses comes from that page (that would be a test page and you
would have specified it in the beginXXX() as an HTTP parameter)

2/ In another test, you would not set the Session variable to true and
thus authenticateUser() would return an HTTP redirect (302 code). In
endXXX() you would verify that the response code is 302 and that the
redirect URL is what is expected.

This is what I call "functional unit testing" on the Cactus main page
(at the bottom of the page : http://jakarta.apache.org/cactus).

However, if you wish to do functional use-case testing, I would
recommend you use a tool like HttpUnit which has the notion of a
sequence of HTTP actions (it is called a Web Conversation).

I hope this answers your question ?


> -----Original Message-----
> From: Marko Balabanovic [mailto:marko@cellectivity.com]
> Sent: 22 February 2002 14:33
> To: cactus-user@jakarta.apache.org
> Subject: Concatenating two cactus tests?
> I'm trying to construct a Cactus test that involves stringing together
> several HTTP requests.  Something like:
> 1. Make request A (call method on servlet A)
> 2. Output is a list of items (don't know ahead of time how many will
> returned)
> 3. Make request B for each item on the list (call method on servlet B,
> passing a parameter from the output of the servlet A method, n times)
> Does anyone have any advice on doing something like this?
> The problems are that:
> - I can't really make both requests A and B inside one test method,
> since inside there I cannot change any request parameters (I only have
> handle on HttpServletRequestWrapper, rather that WebRequest)
> - Ideally I could dynamically create a test suite that includes one
> that checks request A and then n tests to check request B.  But to do
> this I need to see the output of request A inside my static suite()
> method.  This seems to be hard as I have no access to any
> request/response objects.
> - If I call another test case or suite from within my suite() method,
> all I get back is a TestResult object, whereas I really need some
> output.  I can't even examine the state of the test case object, since
> the suite() method is executed in the client-side instance whereas the
> test itself happens in the server-side instance.
> Should I be using some tool other that Cactus for this kind of
> Thanks,
> Marko Balabanovic
> --
> To unsubscribe, e-mail:   <mailto:cactus-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:cactus-user-
> help@jakarta.apache.org>

To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>

View raw message