File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes Can we perform unit testing with JUnit for Struts1 application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Can we perform unit testing with JUnit for Struts1 application" Watch "Can we perform unit testing with JUnit for Struts1 application" New topic
Author

Can we perform unit testing with JUnit for Struts1 application

p hasini
Ranch Hand

Joined: Oct 24, 2009
Posts: 92
How do we perform unit testing for Struts1 application.Is it done by writing JUnit test cases?How do we write these test cases for Struts1
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Short answer: yes.

Longer answer: yes, but how easy it is depends on how well structured the application is.

Personally, I rarely test Struts 1 actions themselves--too complicated. Things like StrutsTestCase can help in that regard. The bulk of application functionality, however, should really live in service objects (or whatever terminology you prefer), such that they can be tested outside of Struts, and without the cognitive overhead of mocking the Struts infrastructure. Actions can be tested by something like Selenium, serving the dual purpose of making sure you're getting the right responses back from the action and the correct view is shown in the browser.
p hasini
Ranch Hand

Joined: Oct 24, 2009
Posts: 92
But StrutsTestCase can be used only with Struts 2.0 framework I think ,cannot use it with Struts1.

Can we use Cactus to test Struts1 Actions?

How do we test the business logic objects.

Please reply
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

From the home page of strutstestcase:
StrutsTestCase is compliant with the Java Servlet 2.2, 2.3, and 2.4 specifications, and supports Struts 1.2/1.3, and Cactus 1.7 and JUnit 3.8.1.
 
Consider Paul's rocket mass heater.
 
subject: Can we perform unit testing with JUnit for Struts1 application