This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes How to easily test a Struts Action? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to easily test a Struts Action?" Watch "How to easily test a Struts Action?" New topic
Author

How to easily test a Struts Action?

gao zhixin
Ranch Hand

Joined: Jan 18, 2006
Posts: 42
Now I'm working with struts, and I want to test my action class, but I need to mock a HttpRequest object, a HttpResponse object, a ActionForm object, and a ActionMapping object, it's too difficult for me to test. Is there anything more easy?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

I dunno... let's go over to the Struts forum and ask over there (I'll move this thread for you.)


[Jess in Action][AskingGoodQuestions]
alan wamser
Ranch Hand

Joined: Jan 30, 2006
Posts: 41
What do you mean by mock? Why not just download tomcat and use it to test your action?

http://localhost/webapp/action.do
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The Apache Cactus is a test framework made specifically for testing Web applications. It builds on JUnit and works great for unit testing Struts applications.

Here's the link:

http://jakarta.apache.org/cactus/
[ January 30, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to easily test a Struts Action?
 
Similar Threads
Form Variables vs Session Variables
Good book for struts
Domain Object as Strtus Action form.
How to Download XML file from database?
JUnit and mocking objects in Struts Action class