Well everyone has an opinion so here mine:

I want to unit test my Struts actions in the full Struts context which
includes  the interceptor stack and validation. This way I know my actions
and results are configured correctly since I test them. I also know my
declarative validations are working correctly. I use junit and I really
don't want or have time to have to learn another test tool for integration
testing.

So to do this type of testing I wrote a StrutsTestContext class to run my
actions.
For full info see:
http://glindholm.wordpress.com/2008/06/30/unit-testing-struts-2-actions/

I don't use Spring so this class would need to be tweaked for Spring but you
are welcome to use this as a starting point.

This gives me a lot of flexibility for testing, sometimes I test against an
actual database (with hibernate) and sometimes I mock the services that the
actions use.



On Thu, Jul 16, 2009 at 10:43 AM, Dimitrios Christodoulakis <
dimi....@gmail.com> 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:
>
> http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/
> 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: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

Reply via email to