This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
Greenhorn
Posts: 17
  • 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
 
author & internet detective
Posts: 39286
745
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: 17
  • 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
Posts: 39286
745
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.
 
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!