struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wes Wannemacher <>
Subject Re: unit testing Struts2 application (with Spring and Hibernate)
Date Thu, 16 Jul 2009 15:28:37 GMT
I have a few thoughts on this, but I am somewhat opinionated when it
comes to unit testing. Personally, I don't think it's necessary to
test your actions with the interceptors. If you want to make sure that
your actions fit into the struts flow of things, then unit testing is
probably not the right place to do it. Personally, I would suggest
that you check out selenium. In my (somewhat convoluted) opinion,
tests should be thought of as one of two possible types... unit and
integration tests. If you are unit testing, you should have created a
small enough unit of work in your code that you can whip up a unit
test that simply makes sure that your unit is doing what you intended
it to do. In my opinion, unit testing isn't about creating a
comprehensive set of tests that validates every possible scenario that
could ever happen, it's simply about showing that through the course
of development, you haven't made a change or introduced a bug through
some external dependency. On the other hand, integration testing is
important as well, but you shouldn't try to recreate your whole
platform in JUnit, that's just creating a situation where maintaining
your JUnit housekeeping code is just as much of a pain as writing your
application code. If you want to integration test, then have a system
set aside where you can deploy your app, then create a suite of
selenium tests that will go through the user flows that you expect to
work. The nice thing about this sort of setup is that you are
exercising the framework, by using the framework, not by trying to
recreate and maintain it.

Did I mention that this is just my opinion? :)


On Thu, Jul 16, 2009 at 10:43 AM, Dimitrios
Christodoulakis<> wrote:
> Hello,
> I was hoping to hear the community's views about unit testing a
> Struts2 application which is integrated with Spring and Hibernate. My
> plan is to unit test the actions with the framework's interceptors
> running, rather than each action class in a stand-alone isolated
> fashion.
> What approach do you usually follow? A highly regarded article:
> provides some useful hints and starting points.
> I would like to use Junit 4 with Ant for this. Are there any other
> resources, or documented steps to take as far as you know, or
> recommend?
> I found quite a few bits and pieces searching online, but would
> appreciate any general guidance or advice on how to begin with this.
> Many thanks and regards.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message