struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nils-Helge Garli Hegvik <nil...@gmail.com>
Subject Re: unit testing Struts2 application (with Spring and Hibernate)
Date Thu, 16 Jul 2009 19:48:00 GMT
If it's integration testing you want to do, I've had success embedding
Jetty and doing "full" in-container integration testing. Embedding
Jetty is really easy, and it's pretty fast too. Although not Struts 2
specific, take a look at this article:
http://today.java.net/pub/a/today/2007/04/12/embedded-integration-testing-of-web-applications.html

Nils-H


On Thu, Jul 16, 2009 at 8:27 PM, Dimitrios
Christodoulakis<dimi.chr@gmail.com> wrote:
> Thanks everyone for their opinions. I was indeed hoping to hear both
> sides of this matter, with both bringing valid arguments and make good
> points.
>
> I was wondering with popular frameworks like struts, spring and
> hibernate integrated together and the increasing adoption of test
> driven, and agile development, there should be at least a couple of
> comprehensive, and well documented strategies on how to perform such
> kind of unit testing with the whole working stack included in the unit
> tests.
>
> I am somewhat curious in trying to do this and making it work, so if
> anyone is aware of any other resources, or strategies in addition to
> Greg's article, where Spring is involved, I'd be very interested in
> taking a look at them.
>
> Or, if someone has done such Struts testing before and wouldn't mind
> sharing some high-level advice, or hints toward a good starting point,
> that would be very helpful and I am sure others can find this
> information of value too.
>
> Again, thank you for your input.
>
>
>
>
>
> On Thu, Jul 16, 2009 at 12:19 PM, Greg Lindholm<greg.lindholm@gmail.com> wrote:
>> 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.chr@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-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message