Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create Junit test case for action classes in struts application

 
yakkala krishna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Good Morning.
This is Y.Rama Krishna.i have an idea regarding how to create junit testcases for normal methods in classes.
But i am not having a proper idea for creating test cases for Action classes,execute() method in struts application.

Please try to give me a proper idea how to create test cases for execute() method in a struts application.

With Regards,
Rama Krishna.Y
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rama,
Welcome to JavaRanch!

One thing to keep in mind when unit testing an action is that you will need to use a mock/fake HttpServletRequest object. The jMock and easyMock frameworks are good for this. Other parameters (form, mapping) can be instantiated normally in Java.
 
yakkala krishna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
Rama,
Welcome to JavaRanch!

One thing to keep in mind when unit testing an action is that you will need to use a mock/fake HttpServletRequest object. The jMock and easyMock frameworks are good for this. Other parameters (form, mapping) can be instantiated normally in Java.



Hi Jeanne Boyarsky,

Good Morning.
Good to see your Reply.
I didn't get clear idea.please try to give me any example to explain how to write test cases for action classes in junit.

with regards,
Rama krsihna.Y
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rama,
This page gives an example of using jMock to mock out a request. A Struts class takes a request as a parameter so this part is similar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic