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 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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 41634
    
  55
Something like http://sourceforge.net/projects/junitee/ or http://jakarta.apache.org/cactus/ would let you run tests in a server environment.


Ping & DNS - my free Android networking tools app
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How t write JUnit Test Cases for my servlet