This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Testing and the fly likes How t write JUnit  Test Cases  for my servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How t write JUnit  Test Cases  for my servlet" Watch "How t write JUnit  Test Cases  for my servlet" New topic
Author

How t write JUnit Test Cases for my servlet

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi ,

I have a servlet and inside the doGet() method i have this
// Just checking username and password and authenticating them .



Please let me know how can i write Test Cases for this ??


Thanks in advance.


Save India From Corruption - Anna Hazare.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You could use HTTPUnit, HTMLUnit, Selenium etc.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39541
    
  27
Something like http://sourceforge.net/projects/junitee/ or http://jakarta.apache.org/cactus/ would let you run tests in a server environment.


Ping & DNS - updated with new look and Ping home screen widget
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you .

Now i understood that there a lot of them .

What to choose (The learning curve should be easy )

Any suggetions please
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Personally, I'd test the functionality outside of the servlet. I use servlets (well, not really, but their equivalent) only to marshall data to service objects (or similar). I keep functionality isolated from the Servlet spec as much as possible to make testing easier.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How t write JUnit Test Cases for my servlet
 
Similar Threads
My very own MVC framework...
help me in writing a unit test case for the given servlet
Servlet Request (Integer)
parsing array to method
MD5