On Wed, 16 Mar 2005 14:04:50 -0500 (EST), Frank W. Zammetti
<[EMAIL PROTECTED]> wrote:
> On Wed, March 16, 2005 1:47 pm, Joe Germuska said:
> > I disagree.  Actions are not fine the way they are.  They depend too
> > directly on the Servlet API, which is one of the reasons they are too
> > hard to unit test.
> 
> I agree with that first part, however, I find the unit test point
> interesting (not sure if amusing is the better word or not)...
> 
> Since Actions are supposed to contain no actual functionality and just
> serve as basically an interface between two layers, why would they ever
> really require unit testing?
> 
> I mean, ideally all Actions should be a couple of lines of code, moving
> data from one object (ActionForm) to another (ValueObject) and handing
> that off to some business delegate.  If we agree that's the ideal, does it
> really ultimately matter if it is abstracted away from the servlet API and
> therefore easier to unit test? (I did say I agree with getting away from
> the servlet API, but only out of a sense of simplifying the method
> signature).

I'm thinking this post deserves a St. Paddy's day award for being a 
hidden nugget of gold in a very large pot :)

And here' s what lies on the other end of the rainbow:

First, if you are working on the framework surrounding the Actions,
then a good set of regression tests can be quite helpful. One reason
we are hesitant to make more radical refactorings is because we don't
have a good set of regression tests.  The reason we don't have more
regression tests is because we haven't refactored Actions to be easier
to test :)

Second, if you are building an application, exercising the actions are
an excellent integration test of both the backend and the frontend. A
unit test against an Action can simulate input and actual "drive" a
running application.

It's quite remarkable what can be done with Action tests using a
package like Struts TestCase [http://strutstestcase.sourceforge.net/].

Problem is, packages like Struts TestCase are much harder to create
and maintain than they could be because of the way Actions are now
designed.

Albeit, the original point is sound. In practice, I find that if you have 

* unit tests against the business logic AND 
* unit tests against the pages (using something like Web Canoo), then

tests against the Actions do become redundant. 

The alternate argument being that if you had a solid set of
integration tests against the Actions themselves, then you wouldn't
need something like Web Canoo. :)

-Ted.

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

Reply via email to