You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark <ma...@iinet.net.au> on 2008/09/11 07:31:15 UTC

Unit Testing Struts 2

Hi all:

Does anyone have a working example of unit testing a Struts 2 app?   
I've been looking around for awhile know and found the following  
resources.  However, I've not been able to get any of them to work.

http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing- 
struts-2-actions-spring-junit/
http://www.soft-gems.net/index.php? 
option=com_content&task=view&id=47&Itemid=33
http://struts.apache.org/2.0.8/docs/how-can-we-test-actions.html

I'm using Struts 2.1.3 and want to test Interceptors and result  
types, not just the Action POJO's.

Any help or resources are greatly appreciated!
Mark

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


Re: Unit Testing Struts 2

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
Not in particular. Basically, they all more or less do the same
(although sometime with different approaches to mocking): Set up the
action context, create a mock invocation and invoke intercept on the
interceptor with the mock invocation.

I think this is the smallest and simplest interceptor test:
http://svn.apache.org/repos/asf/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ClearSessionInterceptorTest.java

Nils-H

On Thu, Sep 11, 2008 at 7:48 AM, Mark <ma...@iinet.net.au> wrote:
> I had a look at a few in the 2.0.11.1 source tree.  I couldn't understand
> how they were structured.  I haven't looked at the 2.1.3 source tree.  Is
> there a particular one you would suggest?
>
> Mark
>
> On 11/09/2008, at 3:40 PM, Nils-Helge Garli Hegvik wrote:
>
>> Have you looked at the tests in the source repository?
>>
>> Nils-H
>>
>> On Thu, Sep 11, 2008 at 7:31 AM, Mark <ma...@iinet.net.au> wrote:
>>>
>>> Hi all:
>>>
>>> Does anyone have a working example of unit testing a Struts 2 app?  I've
>>> been looking around for awhile know and found the following resources.
>>>  However, I've not been able to get any of them to work.
>>>
>>>
>>> http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/
>>>
>>> http://www.soft-gems.net/index.php?option=com_content&task=view&id=47&Itemid=33
>>> http://struts.apache.org/2.0.8/docs/how-can-we-test-actions.html
>>>
>>> I'm using Struts 2.1.3 and want to test Interceptors and result types,
>>> not
>>> just the Action POJO's.
>>>
>>> Any help or resources are greatly appreciated!
>>> Mark
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>

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


Re: Unit Testing Struts 2

Posted by Mark <ma...@iinet.net.au>.
I had a look at a few in the 2.0.11.1 source tree.  I couldn't  
understand how they were structured.  I haven't looked at the 2.1.3  
source tree.  Is there a particular one you would suggest?

Mark

On 11/09/2008, at 3:40 PM, Nils-Helge Garli Hegvik wrote:

> Have you looked at the tests in the source repository?
>
> Nils-H
>
> On Thu, Sep 11, 2008 at 7:31 AM, Mark <ma...@iinet.net.au> wrote:
>> Hi all:
>>
>> Does anyone have a working example of unit testing a Struts 2  
>> app?  I've
>> been looking around for awhile know and found the following  
>> resources.
>>  However, I've not been able to get any of them to work.
>>
>> http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing- 
>> struts-2-actions-spring-junit/
>> http://www.soft-gems.net/index.php? 
>> option=com_content&task=view&id=47&Itemid=33
>> http://struts.apache.org/2.0.8/docs/how-can-we-test-actions.html
>>
>> I'm using Struts 2.1.3 and want to test Interceptors and result  
>> types, not
>> just the Action POJO's.
>>
>> Any help or resources are greatly appreciated!
>> Mark
>>
>> ---------------------------------------------------------------------
>> 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


Re: Unit Testing Struts 2

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
Have you looked at the tests in the source repository?

Nils-H

On Thu, Sep 11, 2008 at 7:31 AM, Mark <ma...@iinet.net.au> wrote:
> Hi all:
>
> Does anyone have a working example of unit testing a Struts 2 app?  I've
> been looking around for awhile know and found the following resources.
>  However, I've not been able to get any of them to work.
>
> http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/
> http://www.soft-gems.net/index.php?option=com_content&task=view&id=47&Itemid=33
> http://struts.apache.org/2.0.8/docs/how-can-we-test-actions.html
>
> I'm using Struts 2.1.3 and want to test Interceptors and result types, not
> just the Action POJO's.
>
> Any help or resources are greatly appreciated!
> Mark
>
> ---------------------------------------------------------------------
> 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


Re: Unit Testing Struts 2

Posted by Greg Lindholm <gl...@yahoo.com>.
Here is a blog writeup of what I'm using. It allows you to test interceptors.

http://glindholm.wordpress.com/2008/06/30/unit-testing-struts-2-actions/


Mark-413 wrote:
> 
> Hi all:
> 
> Does anyone have a working example of unit testing a Struts 2 app?   
> I've been looking around for awhile know and found the following  
> resources.  However, I've not been able to get any of them to work.
> 
> http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing- 
> struts-2-actions-spring-junit/
> http://www.soft-gems.net/index.php? 
> option=com_content&task=view&id=47&Itemid=33
> http://struts.apache.org/2.0.8/docs/how-can-we-test-actions.html
> 
> I'm using Struts 2.1.3 and want to test Interceptors and result  
> types, not just the Action POJO's.
> 
> Any help or resources are greatly appreciated!
> Mark
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Unit-Testing-Struts-2-tp19428146p19451533.html
Sent from the Struts - User mailing list archive at Nabble.com.


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