Rusty:

I’m also researching how to best write unit tests for Struts 2 Action
classes.  

Unit testing the business logic, service classes, etc that are outside the
Struts 2 Action class is not the problem.  The problem is unit testing the
Action class that requires the Struts 2 framework and configuration (for
example relies upon the Struts 2 interceptors being fired).

I wrote up a blog article (http://tinyurl.com/nw4jve) on what I’m able to do
so far.  Based on some work done by others, I was able to create a unit test
for an Action class’s validate method.  I've not yet tried it with the
validation being specified in an XML file, so if you could test that option
and let me know that would be helpful.

The blog article cited by Greg didn't come up in my Google and Struts 2 user
mail list searches.  I'm going to study his code (which probably is much
better than my initial attempt).  

As far as the debate that Greg and Wes mention, I feel that having an easy
way to automate testing  your validation logic is one good reason for unit
tests.  It looks like the work done by Greg and others have made it easier
to write a unit test that will test a Struts 2 Action class within the
context of the framework and your application's Struts 2 configuration.






-- 
View this message in context: 
http://www.nabble.com/how-do-you-test-your-action-classes--tp25289507p25297219.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to